📄 buffinout.java
字号:
//利用BufferedInputStream类和BufferedInputStream类来实现两个文件的复制。
import java.io.*;
public class BuffInOut
{
public static void main(String[] args)
{
FileInputStream oFIS =null;
FileOutputStream oFOS = null;
BufferedInputStream oBIS = null;
BufferedOutputStream oBOS = null;
int c;
try
{
oFIS = new FileInputStream("test11_1.txt"); //文件输入流
oBIS = new BufferedInputStream(oFIS); //连接成带缓冲的输入流
oFOS = new FileOutputStream("test11_5.txt"); //文件输出流
oBOS = new BufferedOutputStream(oFOS); //连接成带缓冲的输出流
while((c = oBIS.read())!= -1) //从oBIS对象文件中读取数据
oBOS.write(c); //从向oBOS对象文件中写入数据
oBOS.flush(); //刷新流,强制输出
}catch(FileNotFoundException e1)
{
System.out.println(e1);
}catch(IOException e2)
{
System.out.println(e2);
}
finally
{
try
{
if(oFIS !=null) oFIS.close();
if(oFOS !=null) oFOS.close();
if(oBIS !=null) oBIS.close();
if(oBOS !=null) oBOS.close();
} catch(IOException e3)
{
System.out.println(e3);
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -