import java.io.*;
class fuzhi
{
public static void main(String[] args)
{
FileOutputStream fos=null;//作用整个类
FileInputStream fis=null;
try
{
fos= new FileOutputStream("D:\\ b.JPEG");//复制的
fis=new FileInputStream("D:\\ a.JPEG");//原文件
byte[] buf=new byte[1024];
int len =0;
while ((len=fis.read(buf))!=-1)//读取数组
{
fos.write(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("写入关闭失败");
}
}
}
}
import java.io.*;
class fuzhi
{
public static void main(String[] args)
{
FileOutputStream fos=null;//作用整个类
FileInputStream fis=null;
try
{
fos= new FileOutputStream("D:\\ b.JPEG");//复制的
fis=new FileInputStream("D:\\ a.JPEG");//原文件
byte[] buf=new byte[1024];
int len =0;
while ((len=fis.read(buf))!=-1)//读取数组
{
fos.write(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("写入关闭失败");
}
}
}
}
import java.io.*;
class fuzhi
{
public static void main(String[] args)
{
FileOutputStream fos=null;//作用整个类
FileInputStream fis=null;
try
{
fos= new FileOutputStream("D:\\ b.JPEG");//复制的
fis=new FileInputStream("D:\\ a.JPEG");//原文件
byte[] buf=new byte[1024];
int len =0;
while ((len=fis.read(buf))!=-1)//读取数组
{
fos.write(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("写入关闭失败");
}
}
}
}
异常了,求解啊!!!!!
D:\java0217\day20>java fuzhi
Exception in thread "main" java.lang.RuntimeException: 复制失败
at fuzhi.main(fuzhi.java:34)
|