JAVA開発メモ

 

[リロード]   [新規|編集|差分|添付]   [トップ|一覧|単語検索|最終更新|バックアップ|ヘルプ]

サイトメニュー

import java.io.BufferedOutputStream; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; class ZipInputStreamSample { /** */ public static void main(String[] args) { byte[] buf = new byte[128]; try { ZipInputStream in = new ZipInputStream(new FileInputStream(args[0])); ZipEntry entry; while ((entry = in.getNextEntry()) != null) { String filename = entry.getName(); System.out.println("Extracting " + filename + "."); BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(filename)); int size; while ((size = in.read(buf, 0, buf.length)) != -1) { out.write(buf, 0, size); } in.closeEntry(); out.flush(); out.close(); } in.close(); } catch (IOException e) { e.printStackTrace(); } } } import java.io.BufferedInputStream; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.util.zip.ZipEntry; import java.util.zip.ZipOutputStream; class ZipOutputStreamSample { /** */ public static void main(String[] args) { byte[] buf = new byte[128]; try { ZipOutputStream out = new ZipOutputStream(new FileOutputStream(args[0])); for (int i = 0; i < args.length - 1; i++) { System.out.println("Add to zip from " + args[i + 1] + "."); BufferedInputStream in = new BufferedInputStream(new FileInputStream(args[i + 1])); ZipEntry entry = new ZipEntry(args[i + 1]); out.putNextEntry(entry); int size; while ((size = in.read(buf, 0, buf.length)) != -1) { out.write(buf, 0, size); } out.closeEntry(); in.close(); } out.flush(); out.close(); } catch (IOException e) { e.printStackTrace(); } } }

リロード   新規 編集 差分   トップ 一覧 検索 最終更新 バックアップ   ヘルプ   最終更新のRSS
Last-modified: Tue, 15 Feb 2005 14:08:10 UTC (6300d)
Link: (4985d)

Modified by MT22(Moriwaki Takashi)

"PukiWiki" 1.3.7 Copyright © 2001,2002,2003 PukiWiki Developers Team. License is GNU/GPL.
Based on "PukiWiki" 1.3 by sng
Powered by PHP 7.4.28

HTML convert time to 0.019 sec.