import javax.imageio.*; import java.awt.image.*; import java.awt.*; import java.security.NoSuchAlgorithmException; import java.security.MessageDigest; import java.lang.reflect.*; import java.net.*; import java.io.*; import javax.swing.*; import java.util.regex.*; import java.util.List; import java.util.zip.*; import java.util.*; public class main { public static void main(String[] args) throws Exception { split(args[0]); } static long splitSize = 1024*1024; // 0 = auto static int n; static void split(String path) { try { File file = new File(path); print("== Processing " + path); long destSize = splitSize != 0 ? splitSize : file.length()/2; ZipFile zipFile = new ZipFile(file); Enumeration entries = zipFile.entries(); n = 1; String outPath = path + "." + n; print("Writing " + outPath); FileOutputStream fout = new FileOutputStream(outPath); ZipOutputStream zout = new ZipOutputStream(fout); long size = 0; while (entries.hasMoreElements()) { ZipEntry entry = (ZipEntry) entries.nextElement(); System.out.println("File found: " + entry.getName()); zout.putNextEntry(new ZipEntry(entry.getName())); InputStream fin = zipFile.getInputStream(entry); copyStream(fin, zout); fin.close(); size += entry.getCompressedSize(); if (size >= destSize) { size = 0; zout.close(); fout.close(); ++n; outPath = path + "." + n; print("Writing " + outPath); fout = new FileOutputStream(outPath); zout = new ZipOutputStream(fout); } } zout.close(); fout.close(); zipFile.close(); } catch (Throwable __e) { throw __e instanceof RuntimeException ? (RuntimeException) __e : new RuntimeException(__e); }} static void copyStream(InputStream in, OutputStream out) { try { byte buf[] = new byte[1024]; int l; while (true) { l = in.read(buf); if (l <= 0) break; out.write(buf, 0, l); } } catch (Throwable __e) { throw __e instanceof RuntimeException ? (RuntimeException) __e : new RuntimeException(__e); }} static void print() { System.out.println(); } static void print(Object o) { System.out.println(o); } static void print(long i) { System.out.println(i); } }