[Java基础]字节,字符打印流
Posted Wecccccccc
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了[Java基础]字节,字符打印流相关的知识,希望对你有一定的参考价值。
代码如下:
package PrintWriterPack;
import java.io.FileNotFoundException;
import java.io.PrintWriter;
public class PrintWriterDemo {
public static void main(String[] args) throws FileNotFoundException {
PrintWriter pw = new PrintWriter("D:\\\\JavaDemo\\\\pw.txt");
pw.write("hello");
pw.write("\\r\\n");
pw.flush();
pw.write("\\r\\n");
pw.write("world");
pw.flush();
pw.close();
}
}
package PrintWriterPack;
import java.io.FileNotFoundException;
import java.io.PrintWriter;
public class PrintWriterDemo {
public static void main(String[] args) throws FileNotFoundException {
PrintWriter pw = new PrintWriter("D:\\\\JavaDemo\\\\pw.txt");
pw.println("hello");
pw.flush();
pw.println("world");
pw.flush();
pw.close();
}
}
package PrintWriterPack;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
public class PrintWriterDemo {
public static void main(String[] args) throws IOException {
PrintWriter pw = new PrintWriter(new FileWriter("D:\\\\JavaDemo\\\\pw.txt"),true);
pw.println("hello");
pw.println("world");
pw.close();
}
}
以上是关于[Java基础]字节,字符打印流的主要内容,如果未能解决你的问题,请参考以下文章