Package java.io

Examples of java.io.ByteArrayInputStream.mark()


        System.arraycopy( bos.array(), 4, buf, 0, bos.writerIndex() - 4 );

        ByteArrayInputStream bis = new ByteArrayInputStream( buf );

        if ( bis.markSupported() ) {
            bis.mark( 0 );
        }

        TIOStreamTransport transport = new TIOStreamTransport( bis );
        TBinaryProtocol protocol = new TBinaryProtocol( transport );
View Full Code Here


        byte[] buf = new byte[bos.writerIndex() - 4];
        System.arraycopy( bos.array(), 4, buf, 0, bos.writerIndex() - 4 );
        ByteArrayInputStream bis = new ByteArrayInputStream( buf);

        if ( bis.markSupported() ) {
            bis.mark( 0 );
        }

        TIOStreamTransport transport = new TIOStreamTransport( bis );
        TBinaryProtocol protocol = new TBinaryProtocol( transport );
View Full Code Here

            ByteArrayInputStream bufStream =
                new ByteArrayInputStream(bufArray);
            int available = bufStream.available();

            // total number of values is at the end of the stream
            bufStream.mark(available);
            bufStream.skip(available-1);
            int length = bufStream.read();
            bufStream.reset();

            int[] valueArray = new int[length];
View Full Code Here

            ByteArrayInputStream bufStream =
                new ByteArrayInputStream(bufArray);
            int available = bufStream.available();

            // total number of values is at the end of the stream
            bufStream.mark(available);
            bufStream.skip(available-1);
            int length = bufStream.read();
            bufStream.reset();

            String[] valueArray = new String[length];
View Full Code Here

            {
               outStream.write( (byte)bt );
            }
            InputStream inputStream = new ByteArrayInputStream(outStream.toByteArray());
            inputStream.mark(0);
            Element root = DOMUtils.parse(inputStream);
            pullImportedSchemas(root, streams);
            inputStream.reset();
View Full Code Here

            count++;
            output.write(firstByte);
            if ((firstByte & MPEGFrameHeader.SYNC_BYTE1) == MPEGFrameHeader.SYNC_BYTE1) {
                // if byte is $FF, we must check the following byte if there is one
                if (input.available() > 0) {
                    input.mark(1)// remember where we were, if we don't need to unsynchronize
                    int secondByte = input.read();
                    if ((secondByte & MPEGFrameHeader.SYNC_BYTE2) == MPEGFrameHeader.SYNC_BYTE2) {
                        // we need to unsynchronize here
                        if (logger.isLoggable(Level.FINEST)) {
                            //logger.finest("Writing unsynchronisation bit at:" + count);
View Full Code Here

  @Test
  public void testSkipFully() throws IOException {
    byte inArray[] = new byte[] {0, 1, 2, 3, 4};
    ByteArrayInputStream in = new ByteArrayInputStream(inArray);
    try {
      in.mark(inArray.length);
      IOUtils.skipFully(in, 2);
      IOUtils.skipFully(in, 2);
      try {
        IOUtils.skipFully(in, 2);
        fail("expected to get a PrematureEOFException");
View Full Code Here

    public void HelperFunctions() throws IOException
    {
        String s = "this is a testString so that we can find something from the beginning";
        byte[] sBinary = s.getBytes(Charset.forName("US-ASCII"));
        ByteArrayInputStream stream = new ByteArrayInputStream(sBinary);
        stream.mark(stream.available() + 1);
        boolean result = BinaryLLSDOSDParser.FindString(stream, "this");
        Assert.assertTrue(result);
        Assert.assertEquals(4L, sBinary.length - stream.available());

//        stream.Position = 10L;
View Full Code Here

            throws IOException {
        final ByteArrayInputStream bais = new ByteArrayInputStream(txnBytes);
        InputArchive ia = BinaryInputArchive.getArchive(bais);

        hdr.deserialize(ia, "hdr");
        bais.mark(bais.available());
        Record txn = null;
        switch (hdr.getType()) {
        case OpCode.createSession:
            // This isn't really an error txn; it just has the same
            // format. The error represents the timeout
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.