Package java.io

Examples of java.io.ByteArrayInputStream.skip()


        // If asked, check the Savestate identifier that should be present at the beginning of the file
        if (isSavestate) {
          if (!CartridgeSavestate.checkIdentifier(data))
            throw new IllegalStateException("Invalid Javatari Savestate file");
          // Skips the Savestate identifier
          byteStream.skip(CartridgeSavestate.contentIdentifier.length);
        }
        ObjectInputStream objStream = new ObjectInputStream(byteStream);
        return objStream.readObject();
      } finally {
        if (file != null) file.close();
View Full Code Here


  }

  public ConsoleState getConsoleState() {
    try{
      ByteArrayInputStream byteStream = new ByteArrayInputStream(rom.content);
      byteStream.skip(contentIdentifier.length);
      ObjectInputStream objStream = new ObjectInputStream(byteStream);
      return (ConsoleState) objStream.readObject();
    } catch (Exception ex) {
      // Cast or IO errors
      ex.printStackTrace();
View Full Code Here

    // If JPEG image starts with ff d9 ffd8, strip this sequence from the beginning
    // FF D9 = EOI (end of image)
    // FF D8 = SOI (start of image)
    if ((original[0] == (byte) 0xff) && (original[1] == (byte) 0xd9) && (original[2] == (byte) 0xff) && (original[3] == (byte) 0xd8)) {

      in.skip(4);
    }

    ByteArrayOutputStream out = new ByteArrayOutputStream();
    BufferedImage source;
View Full Code Here

        Assert.assertEquals( request.getId(), protocol.readI64() );

        // test message header length
        if ( bis.markSupported() ) {
            bis.reset();
            bis.skip( headerLength );
        }

        TMessage message = protocol.readMessageBegin();

        Demo.echoString_args args = new Demo.echoString_args();
View Full Code Here

        Assert.assertEquals( Demo.Iface.class.getName(), protocol.readString() );
        Assert.assertEquals( request.getId(), protocol.readI64() );

        if ( bis.markSupported() ) {
            bis.reset();
            bis.skip( headerLength );
        }

        TMessage message = protocol.readMessageBegin();
        Assert.assertEquals( "echoString", message.name );
        Assert.assertEquals( TMessageType.REPLY, message.type );
View Full Code Here

        Assert.assertEquals( Demo.Iface.class.getName(), protocol.readString() );
        Assert.assertEquals( request.getId(), protocol.readI64() );

        if ( bis.markSupported() ) {
            bis.reset();
            bis.skip( headerLength );
        }

        TMessage message = protocol.readMessageBegin();
        Assert.assertEquals( "echoString", message.name );
        Assert.assertEquals( TMessageType.EXCEPTION, message.type );
View Full Code Here

                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];
            for (int i = 0; i < length; i++) {
View Full Code Here

                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];
            for (int i = 0; i < length; i++) {
View Full Code Here

  // automatic.
  public PacketNEIRecipe(ByteBuf stream) throws IOException
  {
    ByteArrayInputStream bytes = new ByteArrayInputStream( stream.array() );
    bytes.skip( stream.readerIndex() );
    NBTTagCompound comp = CompressedStreamTools.readCompressed( bytes );
    if ( comp != null )
    {
      recipe = new ItemStack[9][];
      for (int x = 0; x < recipe.length; x++)
View Full Code Here

        Assert.assertEquals(4L, sBinary.length - stream.available());

//        stream.Position = 10L;
//        stream.reset();
//        stream.mark(stream.available() + 1);
        stream.skip(6L);
        result = BinaryLLSDOSDParser.FindString(stream, "teststring");
        Assert.assertTrue(result);
        Assert.assertEquals(20L, sBinary.length - stream.available());

//        stream.Position = 25L;
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.