📄 sample32_1.java
字号:
package wyf.jc;
import java.io.*;
public class Sample32_1
{
public static void main(String args[])
{
//定义文件字节输入流引用
FileInputStream fin=null;
//定义文件字节输出流引用
FileOutputStream fout=null;
try
{
//创建文件类型的字节输入流并指定源文件
fin=new FileInputStream(args[0]);
//创建文件类型的字节输出流并指定目标文件
fout=new FileOutputStream("1.jpg");
//执行读操作,并将读取的数据记录到read中
int buf=0;
//测试read是否读到文件结尾
while((buf=fin.read())!=-1)
{
//将读取的数据写入到目标文件
fout.write(buf);
}
//打印提示信息
System.out.println("恭喜您,图片已经成功复制!!!");
}
catch(IOException e)
{
e.printStackTrace();
}
finally
{
try
{
//关闭输入流
fin.close();
}
catch(Exception e)
{
e.printStackTrace();
}
try
{
//关闭输出流
fout.close();
}
catch(Exception e)
{
e.printStackTrace();
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -