import java.io.*;
class 缓冲区复制文件
{
public static void main(String[] args)
{
BufferedReader bufr = null;
BufferedWriter bufw = null;
try
{
bufr = new BufferedReader(new FileReader("啊啊啊.txt"));
bufw = new BufferedWriter(new FileWriter("啊啊啊copy.txt"));
String line = null;
while((line=bufr.readLine()) != null)
{
bufw.write(line);
bufw.newLine();
bufw.flush();
}
}
catch(IOException e)
{
throw new RuntimeException("读写失败");
}
finally
{
try
{
if(bufr!=null)
bufr.close();
}
catch(IOException e)
{
throw new RuntimeException("读取关闭失败");
}
try
{
if(bufw!=null)
bufw.close();
}
catch(IOException e)
{
throw new RuntimeException("写入关闭失败");
}
}
}
}
java基础入门---缓冲区复制文件
最新推荐文章于 2023-09-10 12:31:11 发布