易截截图软件、单文件、免安装、纯绿色、仅160KB

Java无需解压直接读取Zip文件里的文件内容

package com.wicresoft.jpo;
import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
import java.util.zip.ZipInputStream;
public class ReadZipUtil {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
try {
readZipFile("D:\\test\\test.zip");
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public static void readZipFile(String file) throws Exception {
ZipFile zf = new ZipFile(file);
InputStream in = new BufferedInputStream(new FileInputStream(file));
ZipInputStream zin = new ZipInputStream(in);
ZipEntry ze;
while ((ze = zin.getNextEntry()) != null) {
if (ze.isDirectory()) {
// System.out.print("directory - " + ze.getName() + " : "
// + ze.getSize() + " bytes");
// System.out.println();
} else {
System.err.println("file - " + ze.getName() + " : "
+ ze.getSize() + " bytes");
long size = ze.getSize();
if (size > 0) {
BufferedReader br = new BufferedReader(
new InputStreamReader(zf.getInputStream(ze)));
String line;
while ((line = br.readLine()) != null) {
System.out.println(line);
}
br.close();
}
System.out.println();
}
}
zin.closeEntry();
}
}
 


相关文档:

使用Java操作文本文件的方法详解


摘要: 最初java是不支持对文本文件的处理的,为了弥补这个缺憾而引入了Reader和Writer两个类 
最初java是不支持对文本文件的处理的,为了弥补这个缺憾而引入了Reader和Writer两个类,这两个类都是抽象类,Writer中 write(char[] ch,int off,int
length),flush()和close()方法为抽象方法,Reader中read(char[] ch, ......

Java内部类访问外部对象的方法

  Java编程时,为类DialogTry2添加关闭窗口事件,我在构造方法中采用事件适配器来实现:
    this.addWindowListener(new WindowAdapter(){
        public void windowClosing(WindowEvent e){
          &nbs ......

Java类被加载时执行的顺序问题

public class Parent
{
    //1
    static int a =  1;
    //2
    static
    {
        a = 10;
        System.out.println("parent static c ......

浅谈java输入输出流

本文转自:http://cyp-034.blog.163.com/blog/static/2823190520074691849380/
stream
代表的是任何有能力产出数据的数据源,或是任何有能力接收数据的接收源。在Java的IO中,所有的stream(包括Inputstream和
Out stream)都包括两种类型:
(1)字节流
 
表示以字节为单位从stream中读取或往stream中写入 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号