BufferedWritter设置缓冲区大小

用BufferedWritter来写入文件,可以设置缓冲区的大小。

File file = new File("D:\\");
File tempFile = File.createTempFile("abc", ".csv", file);
FileOutputStream fos = new FileOutputStream(tempFile);
OutputStreamWriter osWritter = new OutputStreamWriter(fos, "GBK");//设置字符编码
BufferedWriter bufferedWriter = new BufferedWriter(osWritter, 1024);//设置缓冲区大小
bufferedWriter.write("asdfasdf");//写文件

你可能感兴趣的:(Java基础)