public class Test6
{
public static void main(String[] args) throws IOException
{
//简化写法,建立BufferdReader和BufferedWriter两个缓冲,同时借助转换流
BufferedReader bufr=new BufferedReader(new InputStreamReader(new FileInputStream("e:\\1.txt")));
BufferedWriter bufw=new BufferedWriter(new OutputStreamWriter(new FileOutputStream("e:\\2.txt")));
String line=null;
//读取1.txt中的内容
while((line=bufr.readLine())!=null)
{
//写到2.txt中
bufw.write(line);
//换行
bufw.newLine();
//刷新
bufw.flush();
}
//关流
bufw.close();
bufr.close();
}
}
|
|