Whichmethodimplementationswillwritethegivenstrin
Whichmethodimplementationswillwritethegivenstringtoafilenamed"file",usingUTF8encoding?()
IMPLEMENTATIONa:
publicvoidwrite(Stringmsg)throwsIOException{
FileWriterfw=newFileWriter(newFile("file"));
fw.write(msg);
fw.close();
}
IMPLEMENTATIONb:
publicvoidwrite(Stringmsg)throwsIOException{
OutputStreamWriterosw=newOutputStreamWriter(newFileOutputStream("file"),"UTF8");osw.write(msg);
osw.close();
}
IMPLEMENTATIONc:
publicvoidwrite(Stringmsg)throwsIOException{FileWriterfw=newFileWriter(newFile("file"));
fw.setEncoding("UTF8");
fw.write(msg);
fw.close();}
IMPLEMENTATIONd:
publicvoidwrite(Stringmsg)throwsIOException{FilterWriterfw=FilterWriter(newFileWriter("file"),"UTF8");
fw.write(msg);fw.close();
}
IMPLEMENTATIONe:
publicvoidwrite(Stringmsg)throwsIOException{
OutputStreamWriterosw=newOutputStreamWriter(newOutputStream(newFile("file")),"UTF8");
osw.write(msg);
osw.close();
}
参考答案: