复制一个ZIP文件到另一个路径? 如何复制一个ZIP文件到一个新的路径下啊,我用的是读字节 我编的显示的是 filenotfoundexception。万分感谢!!!! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 import java.io.File;import java.io.FileInputStream;import java.io.FileNotFoundException;import java.io.FileOutputStream;import java.io.IOException;import java.io.InputStream;import java.io.OutputStream;public class CopyFile{ public static void main(String[] ags) { String srcFileName = "F:\\系统软件\\src.zip"; String targetFileName = "F:\\系统软件\\target.zip"; InputStream inStream = null; try { inStream = new FileInputStream(srcFileName); } catch (FileNotFoundException e) { System.err.println("读取文件[" + srcFileName + "]发生错误" + "\r\n" + e.getCause()); return; } File targetFile = new File(targetFileName); OutputStream outStream = null; try { targetFile.createNewFile(); outStream = new FileOutputStream(targetFile); byte[] by = new byte[1024]; while (inStream.available() > 0) { inStream.read(by); outStream.write(by); } } catch (IOException e) { System.err.println("创建文件[" + targetFileName + "]发生错误" + "\r\n" + e.getCause()); } finally { if (null != inStream) { try { inStream.close(); } catch (IOException e) { System.err.println(e.getCause()); } } if (null != outStream) { try { outStream.flush(); } catch (IOException e) { System.err.println(e.getCause()); } try { outStream.close(); } catch (IOException e) { System.err.println(e.getCause()); } } } System.out.println("复制完毕!"); }} filenotfoundexception。你读的文件存在吗? to For_suzhen(不懂装懂):存在to jxcfh():不行啊,显示的还是filenotfoundexception 我把你的程序复制过来,然后在F盘建了一个"系统软件"文件夹,里面建了一个src.zip,编译执行通过!明显是你文件不存在了,程序是对的. 哦,忘了说了,我验证的时候,用的是src.war,其实我是要复制一个war文件,因为觉得war就是一个zip文件,所以就这样问大家了。如果由于蔡鸟级引起的错误,还请大家理解。 求个思路 【急!】IE中无法显示Applet,请问如何解决? 如何在J2SE中掉出当前运行程序的标题栏? 我写的扫雷,保证好玩,要的进来,来的有分,黑黑:) 在线等 求用JAVA写一个售票系统 读字符串 如何从内存中检索ctrl + c的数据 ????? JTEXTAREA可以实现这个吗? 关于在Java中进行网络编程的几个问题,望高手不吝赐教! 高分寻求 JNI 的用法? 帮忙用java编写一个输入字符,并能自动统计每个字符输入的次数的程序 关于Sql server的小问题.
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;public class CopyFile
{
public static void main(String[] ags)
{
String srcFileName = "F:\\系统软件\\src.zip";
String targetFileName = "F:\\系统软件\\target.zip";
InputStream inStream = null; try
{
inStream = new FileInputStream(srcFileName);
} catch (FileNotFoundException e)
{
System.err.println("读取文件[" + srcFileName + "]发生错误" + "\r\n"
+ e.getCause());
return;
} File targetFile = new File(targetFileName);
OutputStream outStream = null;
try
{
targetFile.createNewFile(); outStream = new FileOutputStream(targetFile); byte[] by = new byte[1024]; while (inStream.available() > 0)
{
inStream.read(by);
outStream.write(by);
}
} catch (IOException e)
{
System.err.println("创建文件[" + targetFileName + "]发生错误" + "\r\n"
+ e.getCause());
} finally
{
if (null != inStream)
{
try
{
inStream.close();
} catch (IOException e)
{
System.err.println(e.getCause());
}
}
if (null != outStream)
{
try
{
outStream.flush();
} catch (IOException e)
{
System.err.println(e.getCause());
}
try
{
outStream.close();
} catch (IOException e)
{
System.err.println(e.getCause());
}
}
}
System.out.println("复制完毕!");
}
}
你读的文件存在吗?
to jxcfh():不行啊,显示的还是filenotfoundexception