本帖最后由 邹海洋 于 2012-11-23 10:50 编辑
代码;
/*
复制图片
*/
import java.io.*;
class CopyPic
{
public static void main(String[] args)
{
//创建字节流对象与图片相关联
FileOutputStream fos = null ;
FileInputStream fis = null;
try
{
fos = new FileOutputStream("e:\\图片\\3.bmp");
fis = new FileInputStream("e:\\图片\\1.bmp");
byte[] buf = new byte[1024];
int len = 0;
while ((len = fis.read(buf))!= -1)
{
System.out.println(new String (buf,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("关闭异常");
}
}
}
}
现象
|
|