/*
通过缓冲区赋值一个.java文件
readLine方法只返回回车前面的内容,不返回回车符
*/
import java.io.*;
class BufferedDemo
{
public static void main(String[] args)
{
BufferedWriter buffWriter = null;
BufferedReader buffReader = null;
try
{
buffWriter = new BufferedWriter(new FileWriter("bufCopy.txt"));
buffReader = new BufferedReader(new FileReader("buf.txt"));
String line = null;
while((line = buffReader.readLine()) != null)
{
buffWriter.write(line);
buffWriter.newLine();
buffWriter.flush();
}
}
catch (IOException ex)
{
System.out.println(ex.getMessage());
}
finally
{
try
{
if(buffWriter != null)
{
buffWriter.close();
}
if(buffReader != null)
{
buffReader.close();
}
}
catch (IOException ex)
{
System.out.println(ex.getMessage());
}
}
}
}