Java缓冲流写出数据实例

public class BufferedWriterDemo throws IOException {
    public static void main(String[] args) throws IOException  {
          // 创建流对象
        BufferedWriter bw = new BufferedWriter(new FileWriter("out.txt"));
          // 写出数据
        bw.write("hello");
          // 写出换行
        bw.newLine();
        bw.write("world");
        bw.newLine();
        bw.write("!");
        bw.newLine();
        // 释放资源
        bw.close();
    }
}

猜你喜欢

转载自www.cnblogs.com/theworld/p/11650133.html