一,打印流
二,常用方法
三,案例
package Print.sd;
import java.io.FileNotFoundException;
import java.io.PrintStream;
import java.nio.charset.Charset;
public class Main {
public static void main(String[] args) throws FileNotFoundException {
try ( //1,创建一个打印流管道
PrintStream da =new PrintStream("C:\\untitled1\\untitled\\src\\zifuji\\fangfa", Charset.forName("GBK"));
){
da.println(54);
da.println("ghfqohe");
da.println("ghfqohe");
da.println("星火");
da.println("星火");
da.println("星火");
} catch (Exception e) {
e.printStackTrace();
}
}
}
package Print.sd;
import java.io.FileNotFoundException;
import java.io.PrintWriter;
public class Main {
public static void main(String[] args) throws FileNotFoundException {
try ( //1,创建一个打印流管道
PrintWriter da =new PrintWriter("C:\\untitled1\\untitled\\src\\zifuji\\fangfa");
){
da.write("fhadiuf");
da.write("gfhrgiudnf");
} catch (Exception e) {
e.printStackTrace();
}
}
}
四,注意