JAva--io印刷ストリーム
1488 ワード
package cn.bufanli.iodemo;
import java.io.*;
/**
* @author BuShuangLi
* @date 2018/12/27
*
* printStream
* printWriter
* :
* 1. ,
* 2.
* 3. IO ,
*
*
* :
* printStream() File 、String 、 OutputStream
* printWriter() File 、String 、 OutputStream、 Writer
*/
public class PrintDemo {
public static void main(String[] args) throws IOException {
// printMethod();
//
copyMethod();
}
/**
* , File
* print() println
* 100 100
*/
private static void printMethod() throws FileNotFoundException {
//
PrintWriter writer = new PrintWriter(new File("F:\\a.txt"));
writer.print(100);
writer.flush();
writer.close();
}
/**
*
*/
private static void copyMethod() throws IOException {
//
BufferedReader bufferedInputStream = new BufferedReader(new FileReader(new File("f:\\a.txt")));
//
PrintWriter writer = new PrintWriter(new FileWriter(new File("F:\\h.txt")), true);
//
int len =0;
while ((len=bufferedInputStream.read())!=-1){
writer.print(len);
}
bufferedInputStream.close();
writer.close();
}
}