1. 程式人生 > >java:IO流(readLine()和newLine()方法)

java:IO流(readLine()和newLine()方法)

package com.heima.chario;

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

public class Demo4_Bufferered {

	public static void main(String[] args) throws IOException {
		BufferedReader br=new BufferedReader(new FileReader("xxx.txt"));
		BufferedWriter bw=new BufferedWriter(new FileWriter("ooo.txt"));
		String line;
		while((line=br.readLine())!=null) {
			System.out.println(line);
			bw.write(line);
			bw.newLine();   //跨平臺的
//			bw.write("\r\n");//只支援windows系統
		
		}
		br.close();
		bw.close();
		

	}

}