java.util.zip.InflaterInputStream#close ( )源码实例Demo

下面列出了java.util.zip.InflaterInputStream#close ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: Nukkit   文件: ZlibThreadLocal.java
@Override
public byte[] inflate(InputStream stream) throws IOException {
    InflaterInputStream inputStream = new InflaterInputStream(stream);
    FastByteArrayOutputStream outputStream = ThreadCache.fbaos.get();
    outputStream.reset();
    int length;

    byte[] result;
    byte[] buffer = buf.get();
    try {
        while ((length = inputStream.read(buffer)) != -1) {
            outputStream.write(buffer, 0, length);
        }
    } finally {
        result = outputStream.toByteArray();
        outputStream.flush();
        outputStream.close();
        inputStream.close();
    }

    return result;
}
 
源代码2 项目: Jupiter   文件: Zlib.java
public static byte[] inflate(InputStream stream) throws IOException {
    InflaterInputStream inputStream = new InflaterInputStream(stream);
    ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
    byte[] buffer = new byte[1024];
    int length;

    try {
        while ((length = inputStream.read(buffer)) != -1) {
            outputStream.write(buffer, 0, length);
        }
    } finally {
        buffer = outputStream.toByteArray();
        outputStream.flush();
        outputStream.close();
        inputStream.close();
    }

    return buffer;
}
 
源代码3 项目: MonitorClient   文件: ZLibUtil.java
/** 
 * 解压缩 
 * @param is 输入流        
 * @return byte[] 解压缩后的数据 
 */  
public static byte[] decompress(InputStream is) {  
    InflaterInputStream iis = new InflaterInputStream(is);  
    ByteArrayOutputStream o = new ByteArrayOutputStream(1024);  
    byte[] result = null;
    try {  
        int i = 1024;  
        byte[] buf = new byte[i];  
  
        while ((i = iis.read(buf, 0, i)) > 0) {  
            o.write(buf, 0, i);  
        }  
        result = o.toByteArray();
        o.close();
        iis.close();
    } catch (IOException e) {  
        e.printStackTrace();  
    }  
    return   result;
}
 
源代码4 项目: gcs   文件: PdfReader.java
/**
 * A helper to FlateDecode.
 *
 * @param in the input data
 * @param strict <CODE>true</CODE> to read a correct stream. <CODE>false</CODE> to try to read a
 *            corrupted stream
 * @return the decoded data
 */
public static byte[] FlateDecode(byte in[], boolean strict) {
	ByteArrayInputStream stream = new ByteArrayInputStream(in);
	InflaterInputStream zip = new InflaterInputStream(stream);
	ByteArrayOutputStream out = new ByteArrayOutputStream();
	byte b[] = new byte[strict ? 4092 : 1];
	try {
		int n;
		while ((n = zip.read(b)) >= 0) {
			out.write(b, 0, n);
		}
		zip.close();
		out.close();
		return out.toByteArray();
	} catch (Exception e) {
		if (strict) {
			return null;
		}
		return out.toByteArray();
	}
}
 
源代码5 项目: itext2   文件: PdfReader.java
/** A helper to FlateDecode.
 * @param in the input data
 * @param strict <CODE>true</CODE> to read a correct stream. <CODE>false</CODE>
 * to try to read a corrupted stream
 * @return the decoded data
 */
public static byte[] FlateDecode(byte in[], boolean strict) {
    ByteArrayInputStream stream = new ByteArrayInputStream(in);
    InflaterInputStream zip = new InflaterInputStream(stream);
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    byte b[] = new byte[strict ? 4092 : 1];
    try {
        int n;
        while ((n = zip.read(b)) >= 0) {
            out.write(b, 0, n);
        }
        zip.close();
        out.close();
        return out.toByteArray();
    }
    catch (Exception e) {
        if (strict)
            return null;
        return out.toByteArray();
    }
}
 
源代码6 项目: Nukkit   文件: ZlibOriginal.java
@Override
public byte[] inflate(InputStream stream) throws IOException {
    InflaterInputStream inputStream = new InflaterInputStream(stream);
    ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
    byte[] buffer = new byte[1024];
    int length;

    try {
        while ((length = inputStream.read(buffer)) != -1) {
            outputStream.write(buffer, 0, length);
        }
    } finally {
        buffer = outputStream.toByteArray();
        outputStream.flush();
        outputStream.close();
        inputStream.close();
    }

    return buffer;
}
 
源代码7 项目: Nemisys   文件: Zlib.java
public static byte[] inflate(InputStream stream) throws IOException {
    InflaterInputStream inputStream = new InflaterInputStream(stream);
    ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
    byte[] buffer = new byte[1024];
    int length;

    while ((length = inputStream.read(buffer)) != -1) {
        outputStream.write(buffer, 0, length);
    }

    buffer = outputStream.toByteArray();
    outputStream.flush();
    outputStream.close();
    inputStream.close();

    return buffer;
}
 
源代码8 项目: Nukkit   文件: ZlibSingleThreadLowMem.java
@Override
synchronized public byte[] inflate(InputStream stream) throws IOException {
    InflaterInputStream inputStream = new InflaterInputStream(stream);
    ByteArrayOutputStream outputStream = new ByteArrayOutputStream(BUFFER_SIZE);
    byte[] bufferOut;
    int length;

    try {
        while ((length = inputStream.read(buffer)) != -1) {
            outputStream.write(buffer, 0, length);
        }
    } finally {
        outputStream.flush();
        bufferOut = outputStream.toByteArray();
        outputStream.close();
        inputStream.close();
    }

    return bufferOut;
}
 
源代码9 项目: android_9.0.0_r45   文件: BlobBackupHelper.java
private byte[] inflate(byte[] compressedData) {
    byte[] result = null;
    if (compressedData != null) {
        try {
            ByteArrayInputStream source = new ByteArrayInputStream(compressedData);
            DataInputStream headerIn = new DataInputStream(source);
            int version = headerIn.readInt();
            if (version > mCurrentBlobVersion) {
                Log.w(TAG, "Saved payload from unrecognized version " + version);
                return null;
            }

            InflaterInputStream in = new InflaterInputStream(source);
            ByteArrayOutputStream inflated = new ByteArrayOutputStream();
            byte[] buffer = new byte[4096];
            int nRead;
            while ((nRead = in.read(buffer)) > 0) {
                inflated.write(buffer, 0, nRead);
            }
            in.close();
            inflated.flush();
            result = inflated.toByteArray();
            if (DEBUG) {
                Log.v(TAG, "Inflated " + compressedData.length + " bytes to " + result.length);
            }
        } catch (IOException e) {
            // result is still null here
            Log.w(TAG, "Unable to process restored payload: " + e.getMessage());
        }
    }
    return result;
}
 
源代码10 项目: letv   文件: j.java
public static byte[] b(byte[] bArr) {
    int i = 0;
    if (bArr == null) {
        return null;
    }
    InputStream byteArrayInputStream = new ByteArrayInputStream(bArr);
    InflaterInputStream inflaterInputStream = new InflaterInputStream(byteArrayInputStream);
    Object obj = new byte[0];
    Object obj2 = new byte[1024];
    while (true) {
        try {
            Object obj3;
            int read = inflaterInputStream.read(obj2);
            if (read > 0) {
                i += read;
                obj3 = new byte[i];
                System.arraycopy(obj, 0, obj3, 0, obj.length);
                System.arraycopy(obj2, 0, obj3, obj.length, read);
            } else {
                obj3 = obj;
            }
            if (read <= 0) {
                try {
                    byteArrayInputStream.close();
                    inflaterInputStream.close();
                    return obj3;
                } catch (IOException e) {
                    return null;
                }
            }
            obj = obj3;
        } catch (Exception e2) {
            return null;
        }
    }
}
 
源代码11 项目: warp10-platform   文件: INFLATE.java
@Override
public Object apply(WarpScriptStack stack) throws WarpScriptException {
  Object o = stack.pop();

  if (!(o instanceof byte[])) {
    throw new WarpScriptException(getName() + " operates on a byte array.");
  }
  
  byte[] data = (byte[]) o;
  
  ByteArrayInputStream bin = new ByteArrayInputStream(data);
  ByteArrayOutputStream decompressed = new ByteArrayOutputStream(data.length);
  
  byte[] buf = new byte[1024];
  
  try {
    InflaterInputStream in = new InflaterInputStream(bin);

    while(true) {
      int len = in.read(buf);
      
      if (len < 0) {
        break;
      }
      
      decompressed.write(buf, 0, len);
    }
    
    in.close();
  } catch (IOException ioe) {
    throw new WarpScriptException(getName() + " encountered an error while decompressing.", ioe);
  }
  
  stack.push(decompressed.toByteArray());
  
  return stack;
}
 
源代码12 项目: dragonwell8_jdk   文件: ReadParams.java
public static void main(String args[]) throws Exception{
    /* initialise stuff */
    File fn = new File("x.ReadBounds");
    FileOutputStream fout = new FileOutputStream(fn);
    for (int i = 0; i < 32; i++) {
        fout.write(i);
    }
    fout.close();

    byte b[] = new byte[64];
    for(int i = 0; i < 64; i++) {
        b[i] = 1;
    }

    /* test all input streams */
    FileInputStream fis = new FileInputStream(fn);
    doTest(fis);
    doTest1(fis);
    fis.close();

    BufferedInputStream bis =
        new BufferedInputStream(new MyInputStream(1024));
    doTest(bis);
    doTest1(bis);
    bis.close();

    ByteArrayInputStream bais = new ByteArrayInputStream(b);
    doTest(bais);
    doTest1(bais);
    bais.close();

    FileOutputStream fos = new FileOutputStream(fn);
    ObjectOutputStream oos = new ObjectOutputStream(fos);
    oos.writeInt(12345);
    oos.writeObject("Today");
    oos.writeObject(new Integer(32));
    oos.close();
    ObjectInputStream ois = new ObjectInputStream(new FileInputStream(fn));
    doTest(ois);
    doTest1(ois);
    ois.close();

    DataInputStream dis = new DataInputStream(new MyInputStream(1024));
    doTest(dis);
    doTest1(dis);
    dis.close();

    LineNumberInputStream lis =
        new LineNumberInputStream(new MyInputStream(1024));
    doTest(lis);
    doTest1(lis);
    lis.close();

    PipedOutputStream pos = new PipedOutputStream();
    PipedInputStream pis = new PipedInputStream();
    pos.connect(pis);
    pos.write(b, 0, 64);
    doTest(pis);
    doTest1(pis);
    pis.close();

    PushbackInputStream pbis =
        new PushbackInputStream(new MyInputStream(1024));
    doTest(pbis);
    doTest1(pbis);
    pbis.close();

    StringBufferInputStream sbis =
        new StringBufferInputStream(new String(b));
    doTest(sbis);
    doTest1(sbis);
    sbis.close();

    SequenceInputStream sis =
        new SequenceInputStream(new MyInputStream(1024),
                                new MyInputStream(1024));
    doTest(sis);
    doTest1(sis);
    sis.close();

    ZipInputStream zis = new ZipInputStream(new FileInputStream(fn));
    doTest(zis);
    doTest1(zis);
    zis.close();

    byte[] data = new byte[256];
    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    DeflaterOutputStream dos = new DeflaterOutputStream(bos);
    dos.write(data, 0, data.length);
    dos.close();
    InflaterInputStream ifs = new InflaterInputStream
        (new ByteArrayInputStream(bos.toByteArray()));
    doTest(ifs);
    doTest1(ifs);
    ifs.close();

    /* cleanup */
    fn.delete();
}
 
源代码13 项目: TencentKona-8   文件: ReadParams.java
public static void main(String args[]) throws Exception{
    /* initialise stuff */
    File fn = new File("x.ReadBounds");
    FileOutputStream fout = new FileOutputStream(fn);
    for (int i = 0; i < 32; i++) {
        fout.write(i);
    }
    fout.close();

    byte b[] = new byte[64];
    for(int i = 0; i < 64; i++) {
        b[i] = 1;
    }

    /* test all input streams */
    FileInputStream fis = new FileInputStream(fn);
    doTest(fis);
    doTest1(fis);
    fis.close();

    BufferedInputStream bis =
        new BufferedInputStream(new MyInputStream(1024));
    doTest(bis);
    doTest1(bis);
    bis.close();

    ByteArrayInputStream bais = new ByteArrayInputStream(b);
    doTest(bais);
    doTest1(bais);
    bais.close();

    FileOutputStream fos = new FileOutputStream(fn);
    ObjectOutputStream oos = new ObjectOutputStream(fos);
    oos.writeInt(12345);
    oos.writeObject("Today");
    oos.writeObject(new Integer(32));
    oos.close();
    ObjectInputStream ois = new ObjectInputStream(new FileInputStream(fn));
    doTest(ois);
    doTest1(ois);
    ois.close();

    DataInputStream dis = new DataInputStream(new MyInputStream(1024));
    doTest(dis);
    doTest1(dis);
    dis.close();

    LineNumberInputStream lis =
        new LineNumberInputStream(new MyInputStream(1024));
    doTest(lis);
    doTest1(lis);
    lis.close();

    PipedOutputStream pos = new PipedOutputStream();
    PipedInputStream pis = new PipedInputStream();
    pos.connect(pis);
    pos.write(b, 0, 64);
    doTest(pis);
    doTest1(pis);
    pis.close();

    PushbackInputStream pbis =
        new PushbackInputStream(new MyInputStream(1024));
    doTest(pbis);
    doTest1(pbis);
    pbis.close();

    StringBufferInputStream sbis =
        new StringBufferInputStream(new String(b));
    doTest(sbis);
    doTest1(sbis);
    sbis.close();

    SequenceInputStream sis =
        new SequenceInputStream(new MyInputStream(1024),
                                new MyInputStream(1024));
    doTest(sis);
    doTest1(sis);
    sis.close();

    ZipInputStream zis = new ZipInputStream(new FileInputStream(fn));
    doTest(zis);
    doTest1(zis);
    zis.close();

    byte[] data = new byte[256];
    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    DeflaterOutputStream dos = new DeflaterOutputStream(bos);
    dos.write(data, 0, data.length);
    dos.close();
    InflaterInputStream ifs = new InflaterInputStream
        (new ByteArrayInputStream(bos.toByteArray()));
    doTest(ifs);
    doTest1(ifs);
    ifs.close();

    /* cleanup */
    fn.delete();
}
 
源代码14 项目: openjdk-jdk8u   文件: ReadParams.java
public static void main(String args[]) throws Exception{
    /* initialise stuff */
    File fn = new File("x.ReadBounds");
    FileOutputStream fout = new FileOutputStream(fn);
    for (int i = 0; i < 32; i++) {
        fout.write(i);
    }
    fout.close();

    byte b[] = new byte[64];
    for(int i = 0; i < 64; i++) {
        b[i] = 1;
    }

    /* test all input streams */
    FileInputStream fis = new FileInputStream(fn);
    doTest(fis);
    doTest1(fis);
    fis.close();

    BufferedInputStream bis =
        new BufferedInputStream(new MyInputStream(1024));
    doTest(bis);
    doTest1(bis);
    bis.close();

    ByteArrayInputStream bais = new ByteArrayInputStream(b);
    doTest(bais);
    doTest1(bais);
    bais.close();

    FileOutputStream fos = new FileOutputStream(fn);
    ObjectOutputStream oos = new ObjectOutputStream(fos);
    oos.writeInt(12345);
    oos.writeObject("Today");
    oos.writeObject(new Integer(32));
    oos.close();
    ObjectInputStream ois = new ObjectInputStream(new FileInputStream(fn));
    doTest(ois);
    doTest1(ois);
    ois.close();

    DataInputStream dis = new DataInputStream(new MyInputStream(1024));
    doTest(dis);
    doTest1(dis);
    dis.close();

    LineNumberInputStream lis =
        new LineNumberInputStream(new MyInputStream(1024));
    doTest(lis);
    doTest1(lis);
    lis.close();

    PipedOutputStream pos = new PipedOutputStream();
    PipedInputStream pis = new PipedInputStream();
    pos.connect(pis);
    pos.write(b, 0, 64);
    doTest(pis);
    doTest1(pis);
    pis.close();

    PushbackInputStream pbis =
        new PushbackInputStream(new MyInputStream(1024));
    doTest(pbis);
    doTest1(pbis);
    pbis.close();

    StringBufferInputStream sbis =
        new StringBufferInputStream(new String(b));
    doTest(sbis);
    doTest1(sbis);
    sbis.close();

    SequenceInputStream sis =
        new SequenceInputStream(new MyInputStream(1024),
                                new MyInputStream(1024));
    doTest(sis);
    doTest1(sis);
    sis.close();

    ZipInputStream zis = new ZipInputStream(new FileInputStream(fn));
    doTest(zis);
    doTest1(zis);
    zis.close();

    byte[] data = new byte[256];
    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    DeflaterOutputStream dos = new DeflaterOutputStream(bos);
    dos.write(data, 0, data.length);
    dos.close();
    InflaterInputStream ifs = new InflaterInputStream
        (new ByteArrayInputStream(bos.toByteArray()));
    doTest(ifs);
    doTest1(ifs);
    ifs.close();

    /* cleanup */
    fn.delete();
}
 
源代码15 项目: openjdk-jdk8u-backup   文件: ReadParams.java
public static void main(String args[]) throws Exception{
    /* initialise stuff */
    File fn = new File("x.ReadBounds");
    FileOutputStream fout = new FileOutputStream(fn);
    for (int i = 0; i < 32; i++) {
        fout.write(i);
    }
    fout.close();

    byte b[] = new byte[64];
    for(int i = 0; i < 64; i++) {
        b[i] = 1;
    }

    /* test all input streams */
    FileInputStream fis = new FileInputStream(fn);
    doTest(fis);
    doTest1(fis);
    fis.close();

    BufferedInputStream bis =
        new BufferedInputStream(new MyInputStream(1024));
    doTest(bis);
    doTest1(bis);
    bis.close();

    ByteArrayInputStream bais = new ByteArrayInputStream(b);
    doTest(bais);
    doTest1(bais);
    bais.close();

    FileOutputStream fos = new FileOutputStream(fn);
    ObjectOutputStream oos = new ObjectOutputStream(fos);
    oos.writeInt(12345);
    oos.writeObject("Today");
    oos.writeObject(new Integer(32));
    oos.close();
    ObjectInputStream ois = new ObjectInputStream(new FileInputStream(fn));
    doTest(ois);
    doTest1(ois);
    ois.close();

    DataInputStream dis = new DataInputStream(new MyInputStream(1024));
    doTest(dis);
    doTest1(dis);
    dis.close();

    LineNumberInputStream lis =
        new LineNumberInputStream(new MyInputStream(1024));
    doTest(lis);
    doTest1(lis);
    lis.close();

    PipedOutputStream pos = new PipedOutputStream();
    PipedInputStream pis = new PipedInputStream();
    pos.connect(pis);
    pos.write(b, 0, 64);
    doTest(pis);
    doTest1(pis);
    pis.close();

    PushbackInputStream pbis =
        new PushbackInputStream(new MyInputStream(1024));
    doTest(pbis);
    doTest1(pbis);
    pbis.close();

    StringBufferInputStream sbis =
        new StringBufferInputStream(new String(b));
    doTest(sbis);
    doTest1(sbis);
    sbis.close();

    SequenceInputStream sis =
        new SequenceInputStream(new MyInputStream(1024),
                                new MyInputStream(1024));
    doTest(sis);
    doTest1(sis);
    sis.close();

    ZipInputStream zis = new ZipInputStream(new FileInputStream(fn));
    doTest(zis);
    doTest1(zis);
    zis.close();

    byte[] data = new byte[256];
    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    DeflaterOutputStream dos = new DeflaterOutputStream(bos);
    dos.write(data, 0, data.length);
    dos.close();
    InflaterInputStream ifs = new InflaterInputStream
        (new ByteArrayInputStream(bos.toByteArray()));
    doTest(ifs);
    doTest1(ifs);
    ifs.close();

    /* cleanup */
    fn.delete();
}
 
源代码16 项目: openjdk-jdk9   文件: ReadParams.java
public static void main(String args[]) throws Exception{
    /* initialise stuff */
    File fn = new File("x.ReadBounds");
    FileOutputStream fout = new FileOutputStream(fn);
    for (int i = 0; i < 32; i++) {
        fout.write(i);
    }
    fout.close();

    byte b[] = new byte[64];
    for(int i = 0; i < 64; i++) {
        b[i] = 1;
    }

    /* test all input streams */
    FileInputStream fis = new FileInputStream(fn);
    doTest(fis);
    doTest1(fis);
    fis.close();

    BufferedInputStream bis =
        new BufferedInputStream(new MyInputStream(1024));
    doTest(bis);
    doTest1(bis);
    bis.close();

    ByteArrayInputStream bais = new ByteArrayInputStream(b);
    doTest(bais);
    doTest1(bais);
    bais.close();

    FileOutputStream fos = new FileOutputStream(fn);
    ObjectOutputStream oos = new ObjectOutputStream(fos);
    oos.writeInt(12345);
    oos.writeObject("Today");
    oos.writeObject(new Integer(32));
    oos.close();
    ObjectInputStream ois = new ObjectInputStream(new FileInputStream(fn));
    doTest(ois);
    doTest1(ois);
    ois.close();

    DataInputStream dis = new DataInputStream(new MyInputStream(1024));
    doTest(dis);
    doTest1(dis);
    dis.close();

    LineNumberInputStream lis =
        new LineNumberInputStream(new MyInputStream(1024));
    doTest(lis);
    doTest1(lis);
    lis.close();

    PipedOutputStream pos = new PipedOutputStream();
    PipedInputStream pis = new PipedInputStream();
    pos.connect(pis);
    pos.write(b, 0, 64);
    doTest(pis);
    doTest1(pis);
    pis.close();

    PushbackInputStream pbis =
        new PushbackInputStream(new MyInputStream(1024));
    doTest(pbis);
    doTest1(pbis);
    pbis.close();

    StringBufferInputStream sbis =
        new StringBufferInputStream(new String(b));
    doTest(sbis);
    doTest1(sbis);
    sbis.close();

    SequenceInputStream sis =
        new SequenceInputStream(new MyInputStream(1024),
                                new MyInputStream(1024));
    doTest(sis);
    doTest1(sis);
    sis.close();

    ZipInputStream zis = new ZipInputStream(new FileInputStream(fn));
    doTest(zis);
    doTest1(zis);
    zis.close();

    byte[] data = new byte[256];
    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    DeflaterOutputStream dos = new DeflaterOutputStream(bos);
    dos.write(data, 0, data.length);
    dos.close();
    InflaterInputStream ifs = new InflaterInputStream
        (new ByteArrayInputStream(bos.toByteArray()));
    doTest(ifs);
    doTest1(ifs);
    ifs.close();

    /* cleanup */
    fn.delete();
}
 
源代码17 项目: jdk8u-jdk   文件: ReadParams.java
public static void main(String args[]) throws Exception{
    /* initialise stuff */
    File fn = new File("x.ReadBounds");
    FileOutputStream fout = new FileOutputStream(fn);
    for (int i = 0; i < 32; i++) {
        fout.write(i);
    }
    fout.close();

    byte b[] = new byte[64];
    for(int i = 0; i < 64; i++) {
        b[i] = 1;
    }

    /* test all input streams */
    FileInputStream fis = new FileInputStream(fn);
    doTest(fis);
    doTest1(fis);
    fis.close();

    BufferedInputStream bis =
        new BufferedInputStream(new MyInputStream(1024));
    doTest(bis);
    doTest1(bis);
    bis.close();

    ByteArrayInputStream bais = new ByteArrayInputStream(b);
    doTest(bais);
    doTest1(bais);
    bais.close();

    FileOutputStream fos = new FileOutputStream(fn);
    ObjectOutputStream oos = new ObjectOutputStream(fos);
    oos.writeInt(12345);
    oos.writeObject("Today");
    oos.writeObject(new Integer(32));
    oos.close();
    ObjectInputStream ois = new ObjectInputStream(new FileInputStream(fn));
    doTest(ois);
    doTest1(ois);
    ois.close();

    DataInputStream dis = new DataInputStream(new MyInputStream(1024));
    doTest(dis);
    doTest1(dis);
    dis.close();

    LineNumberInputStream lis =
        new LineNumberInputStream(new MyInputStream(1024));
    doTest(lis);
    doTest1(lis);
    lis.close();

    PipedOutputStream pos = new PipedOutputStream();
    PipedInputStream pis = new PipedInputStream();
    pos.connect(pis);
    pos.write(b, 0, 64);
    doTest(pis);
    doTest1(pis);
    pis.close();

    PushbackInputStream pbis =
        new PushbackInputStream(new MyInputStream(1024));
    doTest(pbis);
    doTest1(pbis);
    pbis.close();

    StringBufferInputStream sbis =
        new StringBufferInputStream(new String(b));
    doTest(sbis);
    doTest1(sbis);
    sbis.close();

    SequenceInputStream sis =
        new SequenceInputStream(new MyInputStream(1024),
                                new MyInputStream(1024));
    doTest(sis);
    doTest1(sis);
    sis.close();

    ZipInputStream zis = new ZipInputStream(new FileInputStream(fn));
    doTest(zis);
    doTest1(zis);
    zis.close();

    byte[] data = new byte[256];
    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    DeflaterOutputStream dos = new DeflaterOutputStream(bos);
    dos.write(data, 0, data.length);
    dos.close();
    InflaterInputStream ifs = new InflaterInputStream
        (new ByteArrayInputStream(bos.toByteArray()));
    doTest(ifs);
    doTest1(ifs);
    ifs.close();

    /* cleanup */
    fn.delete();
}
 
源代码18 项目: openjdk-8-source   文件: ReadParams.java
public static void main(String args[]) throws Exception{
    /* initialise stuff */
    File fn = new File("x.ReadBounds");
    FileOutputStream fout = new FileOutputStream(fn);
    for (int i = 0; i < 32; i++) {
        fout.write(i);
    }
    fout.close();

    byte b[] = new byte[64];
    for(int i = 0; i < 64; i++) {
        b[i] = 1;
    }

    /* test all input streams */
    FileInputStream fis = new FileInputStream(fn);
    doTest(fis);
    doTest1(fis);
    fis.close();

    BufferedInputStream bis =
        new BufferedInputStream(new MyInputStream(1024));
    doTest(bis);
    doTest1(bis);
    bis.close();

    ByteArrayInputStream bais = new ByteArrayInputStream(b);
    doTest(bais);
    doTest1(bais);
    bais.close();

    FileOutputStream fos = new FileOutputStream(fn);
    ObjectOutputStream oos = new ObjectOutputStream(fos);
    oos.writeInt(12345);
    oos.writeObject("Today");
    oos.writeObject(new Integer(32));
    oos.close();
    ObjectInputStream ois = new ObjectInputStream(new FileInputStream(fn));
    doTest(ois);
    doTest1(ois);
    ois.close();

    DataInputStream dis = new DataInputStream(new MyInputStream(1024));
    doTest(dis);
    doTest1(dis);
    dis.close();

    LineNumberInputStream lis =
        new LineNumberInputStream(new MyInputStream(1024));
    doTest(lis);
    doTest1(lis);
    lis.close();

    PipedOutputStream pos = new PipedOutputStream();
    PipedInputStream pis = new PipedInputStream();
    pos.connect(pis);
    pos.write(b, 0, 64);
    doTest(pis);
    doTest1(pis);
    pis.close();

    PushbackInputStream pbis =
        new PushbackInputStream(new MyInputStream(1024));
    doTest(pbis);
    doTest1(pbis);
    pbis.close();

    StringBufferInputStream sbis =
        new StringBufferInputStream(new String(b));
    doTest(sbis);
    doTest1(sbis);
    sbis.close();

    SequenceInputStream sis =
        new SequenceInputStream(new MyInputStream(1024),
                                new MyInputStream(1024));
    doTest(sis);
    doTest1(sis);
    sis.close();

    ZipInputStream zis = new ZipInputStream(new FileInputStream(fn));
    doTest(zis);
    doTest1(zis);
    zis.close();

    byte[] data = new byte[256];
    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    DeflaterOutputStream dos = new DeflaterOutputStream(bos);
    dos.write(data, 0, data.length);
    dos.close();
    InflaterInputStream ifs = new InflaterInputStream
        (new ByteArrayInputStream(bos.toByteArray()));
    doTest(ifs);
    doTest1(ifs);
    ifs.close();

    /* cleanup */
    fn.delete();
}
 
源代码19 项目: openjdk-8   文件: ReadParams.java
public static void main(String args[]) throws Exception{
    /* initialise stuff */
    File fn = new File("x.ReadBounds");
    FileOutputStream fout = new FileOutputStream(fn);
    for (int i = 0; i < 32; i++) {
        fout.write(i);
    }
    fout.close();

    byte b[] = new byte[64];
    for(int i = 0; i < 64; i++) {
        b[i] = 1;
    }

    /* test all input streams */
    FileInputStream fis = new FileInputStream(fn);
    doTest(fis);
    doTest1(fis);
    fis.close();

    BufferedInputStream bis =
        new BufferedInputStream(new MyInputStream(1024));
    doTest(bis);
    doTest1(bis);
    bis.close();

    ByteArrayInputStream bais = new ByteArrayInputStream(b);
    doTest(bais);
    doTest1(bais);
    bais.close();

    FileOutputStream fos = new FileOutputStream(fn);
    ObjectOutputStream oos = new ObjectOutputStream(fos);
    oos.writeInt(12345);
    oos.writeObject("Today");
    oos.writeObject(new Integer(32));
    oos.close();
    ObjectInputStream ois = new ObjectInputStream(new FileInputStream(fn));
    doTest(ois);
    doTest1(ois);
    ois.close();

    DataInputStream dis = new DataInputStream(new MyInputStream(1024));
    doTest(dis);
    doTest1(dis);
    dis.close();

    LineNumberInputStream lis =
        new LineNumberInputStream(new MyInputStream(1024));
    doTest(lis);
    doTest1(lis);
    lis.close();

    PipedOutputStream pos = new PipedOutputStream();
    PipedInputStream pis = new PipedInputStream();
    pos.connect(pis);
    pos.write(b, 0, 64);
    doTest(pis);
    doTest1(pis);
    pis.close();

    PushbackInputStream pbis =
        new PushbackInputStream(new MyInputStream(1024));
    doTest(pbis);
    doTest1(pbis);
    pbis.close();

    StringBufferInputStream sbis =
        new StringBufferInputStream(new String(b));
    doTest(sbis);
    doTest1(sbis);
    sbis.close();

    SequenceInputStream sis =
        new SequenceInputStream(new MyInputStream(1024),
                                new MyInputStream(1024));
    doTest(sis);
    doTest1(sis);
    sis.close();

    ZipInputStream zis = new ZipInputStream(new FileInputStream(fn));
    doTest(zis);
    doTest1(zis);
    zis.close();

    byte[] data = new byte[256];
    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    DeflaterOutputStream dos = new DeflaterOutputStream(bos);
    dos.write(data, 0, data.length);
    dos.close();
    InflaterInputStream ifs = new InflaterInputStream
        (new ByteArrayInputStream(bos.toByteArray()));
    doTest(ifs);
    doTest1(ifs);
    ifs.close();

    /* cleanup */
    fn.delete();
}
 
源代码20 项目: jdk8u_jdk   文件: ReadParams.java
public static void main(String args[]) throws Exception{
    /* initialise stuff */
    File fn = new File("x.ReadBounds");
    FileOutputStream fout = new FileOutputStream(fn);
    for (int i = 0; i < 32; i++) {
        fout.write(i);
    }
    fout.close();

    byte b[] = new byte[64];
    for(int i = 0; i < 64; i++) {
        b[i] = 1;
    }

    /* test all input streams */
    FileInputStream fis = new FileInputStream(fn);
    doTest(fis);
    doTest1(fis);
    fis.close();

    BufferedInputStream bis =
        new BufferedInputStream(new MyInputStream(1024));
    doTest(bis);
    doTest1(bis);
    bis.close();

    ByteArrayInputStream bais = new ByteArrayInputStream(b);
    doTest(bais);
    doTest1(bais);
    bais.close();

    FileOutputStream fos = new FileOutputStream(fn);
    ObjectOutputStream oos = new ObjectOutputStream(fos);
    oos.writeInt(12345);
    oos.writeObject("Today");
    oos.writeObject(new Integer(32));
    oos.close();
    ObjectInputStream ois = new ObjectInputStream(new FileInputStream(fn));
    doTest(ois);
    doTest1(ois);
    ois.close();

    DataInputStream dis = new DataInputStream(new MyInputStream(1024));
    doTest(dis);
    doTest1(dis);
    dis.close();

    LineNumberInputStream lis =
        new LineNumberInputStream(new MyInputStream(1024));
    doTest(lis);
    doTest1(lis);
    lis.close();

    PipedOutputStream pos = new PipedOutputStream();
    PipedInputStream pis = new PipedInputStream();
    pos.connect(pis);
    pos.write(b, 0, 64);
    doTest(pis);
    doTest1(pis);
    pis.close();

    PushbackInputStream pbis =
        new PushbackInputStream(new MyInputStream(1024));
    doTest(pbis);
    doTest1(pbis);
    pbis.close();

    StringBufferInputStream sbis =
        new StringBufferInputStream(new String(b));
    doTest(sbis);
    doTest1(sbis);
    sbis.close();

    SequenceInputStream sis =
        new SequenceInputStream(new MyInputStream(1024),
                                new MyInputStream(1024));
    doTest(sis);
    doTest1(sis);
    sis.close();

    ZipInputStream zis = new ZipInputStream(new FileInputStream(fn));
    doTest(zis);
    doTest1(zis);
    zis.close();

    byte[] data = new byte[256];
    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    DeflaterOutputStream dos = new DeflaterOutputStream(bos);
    dos.write(data, 0, data.length);
    dos.close();
    InflaterInputStream ifs = new InflaterInputStream
        (new ByteArrayInputStream(bos.toByteArray()));
    doTest(ifs);
    doTest1(ifs);
    ifs.close();

    /* cleanup */
    fn.delete();
}
 
 同类方法