자바 IO 는 버퍼 로 텍스트 를 복사 합 니 다.

834 단어 자바 학습
package io.charstream.buffer.test;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.nio.Buffer;

public class CopyTextByBufTest {

	public static void main(String[] args) throws IOException {
		FileReader fr=new FileReader("buf.txt");
		
		BufferedReader bufr=new BufferedReader(fr);
		
		FileWriter fw=new FileWriter("buf_copy1.txt");		
		BufferedWriter bufw=new BufferedWriter(fw);
		
		String line=null;
		while((line=bufr.readLine())!=null) {
			bufw.write(line);
			bufw.newLine();
			bufw.flush(); 
		}
		
		
	/*	int ch=0;
		while((ch=bufr.read())!=-1){//                
			
			bufw.write(ch);
		}*/
		
		bufw.close();
		bufr.close();
	}

}

좋은 웹페이지 즐겨찾기