ziptest.java

来自「oraily的Swing hacks code」· Java 代码 · 共 42 行

JAVA
42
字号
import java.util.zip.*;import java.io.*;import java.util.*;import javax.swing.*;import javax.swing.filechooser.*;import java.net.*;public class ZipTest {    public static void p(String str) {        System.out.println(str);    }        public static void main(String[] args) throws Exception {        FileSystemView fsv = new ZipFileSystemView();        JFileChooser chooser = new JFileChooser(".");        chooser.setFileSystemView(fsv);        chooser.showOpenDialog(null);        File file = chooser.getSelectedFile();        System.out.println("Got the file: " + file + " " + file.getClass());                        InputStream in = null;        if(file instanceof ZipEntryFileProxy) {            in = ((ZipEntryFileProxy)file).getInputStream();        } else {            in = new FileInputStream(file);        }        byte[] buf = new byte[1024];        while(true) {            int n = in.read(buf);            if(n < 0) break;            System.out.write(buf,0,n);        }                                System.exit(0);    }}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?