public FileWriter(String fileName) throws IOException {
super(new FileOutputStream(fileName));
}
public FileWriter(String fileName, boolean append) throws IOException {
super(new FileOutputStream(fileName, append));
}
public FileWriter(File file) throws IOException {
super(new FileOutputStream(file));
}
public FileWriter(File file, boolean append) throws IOException {
super(new FileOutputStream(file, append));
}
public FileWriter(FileDescriptor fd) {
super(new FileOutputStream(fd));
}
在搜索它们之间的差异后,我发现在这里提到。
FileOutputStream 适用于编写原始字节流,例如图像数据。如果要编写字符流,请考虑使用 FileWriter。
FileWriter
如何产生差异?即使它仍然调用 FileOutputStream
的构造函数而没有进行任何更改。
write()
方法。 - Tunaki