為了幫助廣大考試新手們更加順利地複習備考,小編整理了JAVA文件解壓縮的相關實例,希望能夠對大家學習java有所幫助。
Java實現壓縮文件的'解壓縮操作,缺點是壓縮文件內不能含有文件名為中文的的文件,否則會出現如下錯誤:
Exception in thread "main" galArgumentException: MALFORMED
at ring(Unknown Source)
at LOC(Unknown Source)
at extEntry(Unknown Source)
at ()
代碼:
package ;
import ;
import InputStream;
import OutputStream;
import tStream;
import utStream;
import ntry;
import ile;
import nputStream;
public class ZipFileDemo {
@SuppressWarnings("resource")
public static void main(String args[]) throws Exception {
File file = new File("d:" + rator + "");
File outFile = null;
ZipFile zipFile = new ZipFile(file);
ZipInputStream zipInput = new ZipInputStream(new FileInputStream(file));
ZipEntry entry = null;
InputStream input = null;
OutputStream out = null;
while ((entry = extEntry()) != null) {
tln("開始解壓縮" + ame() + "文件。。。");
outFile = new File("d:" + rator + ame());
if (!arentFile()ts()) {
arentFile()r();
}
if (!ts()) {
teNewFile();
}
input = nputStream(entry);
out = new FileOutputStream(outFile);
int temp = 0;
while ((temp = ()) != -1) {
//tln(temp);
e(temp);
}
e();
e();
}
tln("Done!");
}
}