我在C:\ tem \ test目录中的本地计算机上有一个zip文件。我想在新目录中的服务器上提取它,该目录应该与zip文件同名。我怎么能这样做?
class UnZipFile {
final static File source = new File("C:\\tmp\\test\\R1112B2_BcfiHtm.zip");
public static void getZipFiles() {
try {
String destination ="U:\\root\\intranet\\res\\fi\\test";
byte[] buf = new byte[1024];
ZipInputStream zipinputstream = null;
ZipEntry zipentry;
zipinputstream = new ZipInputStream(
new FileInputStream(source));
zipentry = zipinputstream.getNextEntry();
while (zipentry != null) {
//for each entry to be extracted
String entryName = zipentry.getName();
System.out.println("entryname " + entryName);
int n;
FileOutputStream fileoutputstream;
File newFile = new File(entryName);
String directory = newFile.getParent();
if (directory == null) {
if (newFile.isDirectory())
break;
}
fileoutputstream = new FileOutputStream(
destination + entryName);
while ((n = zipinputstream.read(buf, 0, 1024)) > -1)
fileoutputstream.write(buf, 0, n);
fileoutputstream.close();
zipinputstream.closeEntry();
zipentry = zipinputstream.getNextEntry();
}//while
zipinputstream.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}
我得到以下异常: java.io.FileNotFoundException:C:\ tmp \ test \ Attestn \ 1000100_FormDem_NS_NL.pdf(系统找不到指定的路径)