Package java.io

Examples of java.io.BufferedInputStream.reset()


                // use a buffered input stream to find out whether there actually
                // is a request body
                InputStream bin = new BufferedInputStream(in);
                bin.mark(1);
                boolean isEmpty = -1 == bin.read();
                bin.reset();
                if (!isEmpty) {
                    requestDocument = DomUtil.parseDocument(bin);
                }
            }
        } catch (IOException e) {
View Full Code Here


        // Handle it transparently
        bis.mark( 2 );
        InputStream data;
        if ( bis.read() == 0x1f && bis.read() == 0x8b ) // GZIPInputStream.GZIP_MAGIC
        {
            bis.reset();
            data = new GZIPInputStream( bis, 2 * 1024 );
        }
        else
        {
            bis.reset();
View Full Code Here

            bis.reset();
            data = new GZIPInputStream( bis, 2 * 1024 );
        }
        else
        {
            bis.reset();
            data = bis;
        }

        this.dis = new DataInputStream( data );
    }
View Full Code Here

            // decompress the first 100 bytes using the "zlib"-variant.
            BufferedInputStream bStream = new BufferedInputStream(in);
            bStream.mark(100);
            byte[] bytes = new byte[100];
            int nbBytes = bStream.read(bytes);
            bStream.reset();

            Inflater inflater = new Inflater();
            inflater.setInput(bytes, 0, nbBytes);
            try {
                inflater.inflate(new byte[1000]);
View Full Code Here

    public InputStream unpack(InputStream packed) throws IOException {
        BufferedInputStream buffered = new BufferedInputStream(packed);
        buffered.mark(4);
        byte[] magic = new byte[4];
        buffered.read(magic, 0, 4);
        buffered.reset();

        InputStream in = buffered;

        if (magic[0] == (byte) 0x1F && magic[1] == (byte) 0x8B && magic[2] == (byte) 0x08) {
            // this is a gziped pack200
View Full Code Here

        // No extensions present; the file ended where we expected.
        //
        break;
      }

      in.reset();
      md.update(hdr, 0, 8);
      IO.skipFully(in, 8);

      long sz = NB.decodeUInt32(hdr, 4);
      switch (NB.decodeInt32(hdr, 0)) {
View Full Code Here

        if (head != 0x30)
        {
            throw new IOException("stream does not represent a PKCS12 key store");
        }

        bufIn.reset();

        ASN1InputStream bIn = new ASN1InputStream(bufIn);
        ASN1Sequence    obj = (ASN1Sequence)bIn.readObject();
        Pfx             bag = new Pfx(obj);
        ContentInfo     info = bag.getAuthSafe();
View Full Code Here

        new ByteArrayInputStream(bytes), 12);
    try {
      in.skip(6);
      in.mark(14);
      in.read(new byte[14], 0, 14);
      in.reset();
      assertTrue("Wrong bytes", in.read() == 6 && in.read() == 7);
    } catch (IOException e) {
      fail("Exception during mark test 2");
    }
View Full Code Here

    in = new BufferedInputStream(new ByteArrayInputStream(bytes), 12);
    try {
      in.skip(6);
      in.mark(8);
      in.skip(7);
      in.reset();
      assertTrue("Wrong bytes 2", in.read() == 6 && in.read() == 7);
    } catch (IOException e) {
      fail("Exception during mark test 3");
    }
  }
View Full Code Here

          new ByteArrayInputStream("1234567890".getBytes()));
      bIn.mark(10);
      for (int i = 0; i < 11; i++) {
        bIn.read();
      }
      bIn.reset();

    } catch (IOException e) {
      fail("Exception during reset test");
    }
  }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.