予想されるコンテンツでアーカイブを作成することに成功しましgz
たが、アーカイブ内にファイル名を設定するにはどうすればよいですか?
つまり、アーカイブmyfile.gz
が作成された場合、その中のファイルには「 」という名前が付けられますmyfile
が、ソース ファイルのような名前を付けたいです。1.txt
現在のコード:
public static void gz() throws FileNotFoundException, IOException {
GZIPOutputStream out = null;
String filePaths[] = {"C:/Temp/1.txt","C:/Temp/2.txt"};
try {
out = new GZIPOutputStream(
new BufferedOutputStream(new FileOutputStream("C:/Temp/myfile.gz")));
RandomAccessFile f = new RandomAccessFile(filePaths[0], "r");
byte[] b = new byte[(int)f.length()];
f.read(b);
out.write(b, 0, b.length);
out.finish();
out.close();
} finally {
if(out != null) out.close();
}
}