Package java.io

Examples of java.io.InputStream.markSupported()


                response.commit();

                if (response.getKeepAlive()) {
                    InputStream is = request.getRawInputStream();
                    if (is != null && is.markSupported()) {
                        is.mark(4);
                        if (is.read() != '\r' || is.read() != '\n')
                            is.reset();
                    }
                } else
View Full Code Here


        byte[] src = "HELLO MINA".getBytes();
        byte[] dst = new byte[src.length];
        ByteBuffer bb = ByteBuffer.wrap(src);
        InputStream is = new ByteBufferInputStream(bb);

        assertEquals(true, is.markSupported());
        is.mark(src.length);
        assertEquals(dst.length, is.read(dst));
        assertArrayEquals(src, dst);
        assertEquals(-1, is.read());
        is.close();
View Full Code Here

      {
          SanityManager.THROWASSERT("NDRDAType: " + ndrdaType +
                  " not valid EXTDTA object type");
      }
    }
  if (! is.markSupported()) {
      is = new BufferedInputStream(is);
      }
     
   this.binaryInputStream=is;
    }
View Full Code Here

            hdrInfo = new HeaderInfo(hdrLen, valueLength);
            // Make sure the stream is correctly positioned.
            rewindStream((InputStream)in, hdrLen);
        } else {
            final InputStream srcIn = (InputStream)in;
            final boolean markSet = srcIn.markSupported();
            if (markSet) {
                srcIn.mark(MAX_STREAM_HEADER_LENGTH);
            }
            byte[] header = new byte[MAX_STREAM_HEADER_LENGTH];
            int read = in.read(header);
View Full Code Here

  @Test
  public void testMarkSupported() throws IOException
  {
    InputStream data = new ByteArrayInputStream(DATA);
    CountingInputStream in = new CountingInputStream(data);
    assertEquals(data.markSupported(), in.markSupported());
  }

  @Test
  public void testMarkAndReset() throws IOException
  {
View Full Code Here

    }
    os.close();

    final LZ4FastDecompressor decompressor = LZ4Factory.fastestInstance().fastDecompressor();
    InputStream is = new LZ4BlockInputStream(open(compressed.toByteArray()), decompressor, checksum);
    assertFalse(is.markSupported());
    try {
      is.mark(1);
      is.reset();
      assertFalse(true);
    } catch (IOException e) {
View Full Code Here

  throws IOException {
    InputStream in = fs.open(p);
    try {
      // I need to be able to move back in the stream if this is not a pb serialization so I can
      // do the Writable decoding instead.
      in = in.markSupported()? in: new BufferedInputStream(in);
      int pblen = ProtobufUtil.lengthOfPBMagic();
      in.mark(pblen);
      byte [] pbuf = new byte[pblen];
      int read = in.read(pbuf);
      if (read != pblen) throw new IOException("read=" + read + ", wanted=" + pblen);
View Full Code Here

     
  }catch(IOException e){
      throw new IllegalStateException(e.getMessage());
  }
 
  if(! is.markSupported() ){
      is = new BufferedInputStream(is);
  }

  this.binaryInputStream = is;
View Full Code Here

     */
    public void test_markSupported() {
        InputStream is = new ByteArrayInputStream(new byte[10]);
        InflaterInputStream iis = new InflaterInputStream(is);
        assertFalse(iis.markSupported());
        assertTrue(is.markSupported());
    }

  /**
     * @tests java.util.zip.InflaterInputStream#read()
     */
 
View Full Code Here

                    return wrapped.available();
                }

                @Override
                public boolean markSupported() {
                    return wrapped.markSupported();
                }

                @Override
                public void mark(int readlimit) {
                    wrapped.mark(readlimit);
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.