「Javar」jarまたはzipファイルを読み書きメモ

Javaコード
// jarまたはzipを読む
ZipFile zf = new ZipFile(“startnews.jar");
Enumeration all = zf.entries();
while (all.hasMoreElements()) {
ZipEntry entry = (ZipEntry)all.nextElement();
if (entry.isFile())
println(“Directory: " + entry.getName());

// 读写文件
FileOutputStream os = new FileOutputStream(entry.getName());
InputStream is = zf.getInputStream(entry);
int n = 0;
byte[] b = new byte[8092];
while ((n = is.read(b)) > 0) {
os.write(b, 0, n);
is.close();
os.close();
}
}

// gzip書き込み/読み込み
FileInputStream fin = new FileInputStream(FILENAME);
GZIPInputStream gzis = new GZIPInputStream(fin);
InputStreamReader xover = new InputStreamReader(gzis);
BufferedReader is = new BufferedReader(xover);
String line;
while ((line = is.readLine()) != null)
System.out.println(“Read: " + line);

Java

Posted by arkgame