import java.io.*;
class copypic
{
public static void main(String[] args)
{
FileOutputStream fos = null;
FileInputStream fis = null;
try
{
fos = new FileOutputStream("d:\\1.jpg");
fis = new FileInputStream("d:\\2.jpg");
int len = 0;
byte [] b = new byte[1024];
while((len = fis.read(b))!=-1)
{
fos.write(b,0,len);
}
}
catch (IOException e)
{
throw new RuntimeException("复制文件失败");
}
finally
{
try
{
if(fis!=null)
fis.close();
}
catch (IOException e)
{
throw new RuntimeException("读取关闭失败");
}
try
{
if(fos!=null)
fos.close();
}
catch (IOException e)
{
throw new RuntimeException("写入关闭失败");
}
}
}
}
读取复制图片文件
最新推荐文章于 2018-11-05 18:42:05 发布