fileDir=createFileSaveDir();//创建初始文件名StringfileName=createFileName();//创建文件输出流Buffere...
fileDir = createFileSaveDir();// 创建初始文件名 String fileName = createFileName(); // 创建文件输出流 BufferedWriter writer = createFileWriter(fileName);求助大神java创建文件,但怎么设置编码格式为UTF-8,在线等
代码如下:
public static BufferedWriter createFileWriter(String name) throws FileNotFoundException, UnsupportedEncodingException {
FileOutputStream outputStream = new FileOutputStream(name);
OutputStreamWriter outputWriter = new OutputStreamWriter(outputStream, "utf-8");
BufferedWriter writer = new BufferedWriter(outputWriter);
return writer;
}