我正在瀏覽java文檔,似乎沒有辦法專門解壓縮saz文件,這是由網絡代理Fiddler創建的會話歸檔文件。任何人有任何想法如何做到這一點?解壓縮saz文件java
0
A
回答
2
根據this它是正常的ZIP與文件名的特定擴展名。使用java.util.zip.ZipFile。
關於沒有這種擴展的具體方法 - 我認爲對於每個可能的擴展沒有具體的方法是有意義的。
0
This page,通過谷歌搜索 「SAZ文件」,找到說:
SAZ文件只是特殊格式的.ZIP文件。如果重命名 .SAZ文件.ZIP,你可以打開它使用標準的ZIP 查看工具
查看所以他們只是壓縮的文件擴展名不同。將它們解壓縮,就像解壓zip文件一樣。
1
這應該做的伎倆
SAZ文件是常規的zip文件
public static boolean unzipFiles(String srcDirectory, String srcFile, String destDirectory)
{
try
{
//first make sure that all the arguments are valid and not null
if(srcDirectory == null)
{
System.out.println(1);
return false;
}
if(srcFile == null)
{
System.out.println(2);
return false;
}
if(destDirectory == null)
{
System.out.println(3);
return false;
}
if(srcDirectory.equals(""))
{
System.out.println(4);
return false;
}
if(srcFile.equals(""))
{
System.out.println(5);
return false;
}
if(destDirectory.equals(""))
{
System.out.println(6);
return false;
}
//now make sure that these directories exist
File sourceDirectory = new File(srcDirectory);
File sourceFile = new File(srcDirectory + File.separator + srcFile);
File destinationDirectory = new File(destDirectory);
if(!sourceDirectory.exists())
{
System.out.println(7);
return false;
}
if(!sourceFile.exists())
{
System.out.println(sourceFile);
return false;
}
if(!destinationDirectory.exists())
{
System.out.println(9);
return false;
}
//now start with unzip process
BufferedOutputStream dest = null;
FileInputStream fis = new FileInputStream(sourceFile);
ZipInputStream zis = new ZipInputStream(new BufferedInputStream(fis));
ZipEntry entry = null;
while((entry = zis.getNextEntry()) != null)
{
String outputFilename = destDirectory + File.separator + entry.getName();
System.out.println("Extracting file: " + entry.getName());
createDirIfNeeded(destDirectory, entry);
int count;
byte data[] = new byte[BUFFER_SIZE];
//write the file to the disk
FileOutputStream fos = new FileOutputStream(outputFilename);
dest = new BufferedOutputStream(fos, BUFFER_SIZE);
while((count = zis.read(data, 0, BUFFER_SIZE)) != -1)
{
dest.write(data, 0, count);
}
//close the output streams
dest.flush();
dest.close();
}
//we are done with all the files
//close the zip file
zis.close();
}
catch(Exception e)
{
e.printStackTrace();
return false;
}
return true;
}
相關問題
- 1. java解壓縮文件
- 2. 解壓縮(解壓縮)由.net壓縮(解壓縮)的文件.net system.io.compression.gzipstream
- 3. 解壓縮文件
- 4. 解壓縮文件
- 5. 用java解壓縮文本
- 6. Node.js - 壓縮/解壓縮文件夾
- 7. 壓縮解壓縮的exe文件
- 8. Magick ++壓縮和解壓縮文件
- 9. Java - 解壓縮文件的壓縮方式不同
- 10. 如何解壓/解壓縮文件
- 11. Java LZW壓縮和解壓縮圖像
- 12. Java壓縮和解壓縮byte []塊
- 13. Java:解壓縮明顯慢於壓縮
- 14. 解壓縮Zip文件3.6
- 15. 空氣解壓縮文件
- 16. tomcat和解壓縮文件
- 17. Android - 解壓縮文件夾?
- 18. 解壓縮.zip文件
- 19. 迅速解壓縮文件
- 20. 解壓縮.Z文件
- 21. BlackBerry - 解壓縮Zip文件
- 22. 解壓縮.Z文件C
- 23. 解壓縮tar.gz文件
- 24. 解壓縮log.gz文件
- 25. 解壓縮「wmz」文件
- 26. 解壓縮文件用PHP
- 27. 解壓縮.zip文件
- 28. Perl:解析壓縮文件
- 29. 壓縮/解壓縮文件夾和文件
- 30. 上傳壓縮文件,解壓縮並讀取文件
我不知道是什麼SAZ文件。但是,如果您可以解壓縮它們,那麼它們必須是zip文件,並且可以像解壓縮其他文件一樣解壓縮它們。還是你的意思是「解壓縮」? – 2012-07-30 17:44:22
Sax文件是會話歸檔文件。它們包含http請求和響應。而且我不確定是否定期解壓縮。也許,但我希望有一個特定於saz文件的方式。 – barndog 2012-07-30 17:45:58