Example usage for java.util.zip InflaterInputStream read

List of usage examples for java.util.zip InflaterInputStream read

Introduction

In this page you can find the example usage for java.util.zip InflaterInputStream read.

Prototype

public int read() throws IOException 

Source Link

Document

Reads a byte of uncompressed data.

Usage

From source file:Main.java

public static void main(String[] args) throws Exception {

    FileInputStream fin = new FileInputStream("a.dat");
    InflaterInputStream iis = new InflaterInputStream(fin);
    FileOutputStream fout = new FileOutputStream("b.dat");
    for (int c = iis.read(); c != -1; c = iis.read()) {
        fout.write(c);//w  w  w  . java2 s .c o  m
    }
    fout.close();

}

From source file:Main.java

public static void main(String[] args) {

    for (int i = 0; i < args.length; i++) {
        if (args[i].toLowerCase().endsWith(".dfl")) {
            try {
                FileInputStream fin = new FileInputStream(args[i]);
                InflaterInputStream iis = new InflaterInputStream(fin);
                FileOutputStream fout = new FileOutputStream(args[i].substring(0, args[i].length() - 4));
                for (int c = iis.read(); c != -1; c = iis.read()) {
                    fout.write(c);//  ww w  .  j ava2  s. c  o m
                }
                fout.close();
            } catch (IOException ex) {
                System.err.println(ex);
            }
        } else {
            System.err.println(args[i] + " does not appear to be a deflated file.");
        }
    }
}