Package java.io

Examples of java.io.BufferedInputStream.mark()


     * Parses the current JSON type from a {@link InputStream}. Detects the encoding from the input stream.
     */
    public T from(InputStream stm) throws JsonParserException {
      final BufferedInputStream buffered = stm instanceof BufferedInputStream ? (BufferedInputStream)stm
          : new BufferedInputStream(stm);
      buffered.mark(4);

      try {
        Charset charset;
        int[] sig = new int[] { buffered.read(), buffered.read(), buffered.read(), buffered.read() };
        // Encoding detection based on http://www.ietf.org/rfc/rfc4627.txt
View Full Code Here


   */
  public void set(IStorage iStorage) throws CoreException {
    resetAll();
    InputStream inputStream = iStorage.getContents();
    InputStream resettableStream = new BufferedInputStream(inputStream, CodedIO.MAX_BUF_SIZE);
    resettableStream.mark(CodedIO.MAX_MARK_SIZE);
    set(resettableStream);
    // TODO we'll need to "remember" IFile, or
    // get its (or its project's) settings, in case
    // those are needed to handle cases when the
    // encoding is not in the file stream.
View Full Code Here

  public void set(IFile iFile) throws CoreException {
    resetAll();
    InputStream inputStream = iFile.getContents(true);
    InputStream resettableStream = new BufferedInputStream(inputStream, MAX_BUF_SIZE);
    resettableStream.mark(MAX_MARK_SIZE);
    set(resettableStream);
  }

  public void set(InputStream inputStream) {
    resetAll();
View Full Code Here

            byte[] reply = new byte[size];

            // figure out the stream size as we need to pass it in the header
            BufferedInputStream buffer = new BufferedInputStream(data, size);
            try {
                buffer.mark(Integer.MAX_VALUE);
                while ((read = buffer.read(reply)) != -1) {
                    count += read;
                }

                // send the header
View Full Code Here

            InputStream in = httpRequest.getInputStream();
            if (in != null) {
                // 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);
                }
View Full Code Here

        BufferedInputStream bis = new BufferedInputStream( is, 1024 * 8 );

        // MINDEXER-13
        // LightweightHttpWagon may have performed automatic decompression
        // 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 );
View Full Code Here

            // There seems to be 2 variants of the "deflate"-encoding.
            // I couldn't find a way to auto-detect which variant was
            // used, so as (a not really good) work-around we try do
            // 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();
View Full Code Here

    }

    @Override
    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;
View Full Code Here

    snapshot = FileSnapshot.save(liveFile);

    // After the file entries are index extensions, and then a footer.
    //
    for (;;) {
      in.mark(21);
      IO.readFully(in, hdr, 0, 20);
      if (in.read() < 0) {
        // No extensions present; the file ended where we expected.
        //
        break;
View Full Code Here

            throw new NullPointerException("No password supplied for PKCS#12 KeyStore.");
        }

        BufferedInputStream             bufIn = new BufferedInputStream(stream);

        bufIn.mark(10);

        int head = bufIn.read();

        if (head != 0x30)
        {
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.