📄 zipstuff.java
字号:
//// ZipStuff.java// Simphile//// Created by Brian Risk on Thu May 09 2002.// Copyright (c) 2002 Geneffects. All rights reserved.//import java.io.*;import java.util.zip.*;public abstract class ZipStuff { public static long GZip(File f) { return GZip(f, null); } public static long GZip(File f, File f2) { long out = 0; BufferedInputStream bis = null; BufferedInputStream bis2 = null; try { bis = new BufferedInputStream( new FileInputStream(f)); if (f2 != null) { bis2 = new BufferedInputStream( new FileInputStream(f2)); } } catch (FileNotFoundException e) {} try { ByteArrayOutputStream baos = new ByteArrayOutputStream(); BufferedOutputStream bos = new BufferedOutputStream(baos); GZIPOutputStream gzos = new GZIPOutputStream(bos); transferStreams(bis, gzos); if (f2 != null) {transferStreams(bis2, gzos);} gzos.finish(); gzos.flush(); out = baos.size(); bis.close(); if (f2 != null) {bis2.close();} bos.close(); } catch (IOException e) {} return out; } private static void transferStreams(BufferedInputStream is, GZIPOutputStream os) { try { int bufferSize = 1024; int count = 0; while (is.available() > 0) { byte [] pony = new byte[bufferSize]; while (is.available() >= bufferSize) { count++; is.read(pony, 0, bufferSize); os.write(pony, 0, bufferSize); } bufferSize /= 2; } } catch (IOException e) {} } }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -