我想保留从 Java 中的 gzip 文件中提取的文件的时间戳。
这是代码:
public void gunzipFile(String zipFile, String newFile) {
System.out.println("zipFile: " + zipFile);
final int bufferSize = 1024;
try {
FileInputStream fis = new FileInputStream(zipFile);
BufferedInputStream bis = new BufferedInputStream(fis);
GZIPInputStream gis = new GZIPInputStream(bis);
FileOutputStream fos = new FileOutputStream(newFile);
final byte[] buffer = new byte[bufferSize];
int len = 0;
while ((len = gis.read(buffer)) != -1) {
fos.write(buffer, 0, len);
}
//close resources
fos.close();
gis.close();
} catch (IOException e) {
System.out.println("exception caught");
}
}