skipBytes ( )源码实例Demo

java.io.DataInputStream#skipBytes ( )源码实例Demo

下面列出了java.io.DataInputStream#skipBytes ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: RipplePower   文件: AddressIndexBlock.java
private static byte[] input(byte[] ins, String name) throws IOException {
	int find = Character.toLowerCase(name.charAt(4));
	ByteArrayInputStream tmp = new ByteArrayInputStream(ins);
	DataInputStream in = new DataInputStream(tmp);
	for (;;) {
		in.readInt();
		int valueLength = in.readInt();
		byte keyBuffer = in.readByte();
		if (keyBuffer == find) {
			byte[] valueBuffer = new byte[valueLength];
			in.read(valueBuffer, 0, valueLength);
			return valueBuffer;
		} else {
			in.skipBytes(valueLength);
		}
	}
}
 
源代码2 项目: CameraViewer   文件: RecorderPlayer.java
public int getVideoLength() throws IOException {
    int index = 0;
    mDataInputStream = new DataInputStream(new FileInputStream(mFile));
    mFrameLength = new int[1000];
    while (mDataInputStream.available() > 0) {
        int size = mDataInputStream.readInt();//帧长度
        mFrameLength[index++] = mDataInputStream.readInt();//图像停留时间
        mDataInputStream.skipBytes(size);//跳过图像数据
        //空间不够,要扩充
        if (index == mFrameLength.length) {
            int[] tmp = new int[mFrameLength.length + 1000];
            for (int j = 0; j < index; j++) {
                tmp[j] = mFrameLength[j];
            }
            mFrameLength = tmp;
        }
    }
    mDataInputStream.close();
    return index;
}
 
源代码3 项目: openjdk-8   文件: BinaryAttribute.java
/**
 * Load a list of attributes
 */
public static BinaryAttribute load(DataInputStream in, BinaryConstantPool cpool, int mask) throws IOException {
    BinaryAttribute atts = null;
    int natt = in.readUnsignedShort();  // JVM 4.6 method_info.attrutes_count

    for (int i = 0 ; i < natt ; i++) {
        // id from JVM 4.7 attribute_info.attribute_name_index
        Identifier id = cpool.getIdentifier(in.readUnsignedShort());
        // id from JVM 4.7 attribute_info.attribute_length
        int len = in.readInt();

        if (id.equals(idCode) && ((mask & ATT_CODE) == 0)) {
            in.skipBytes(len);
        } else {
            byte data[] = new byte[len];
            in.readFully(data);
            atts = new BinaryAttribute(id, data, atts);
        }
    }
    return atts;
}
 
源代码4 项目: TencentKona-8   文件: BinaryAttribute.java
/**
 * Load a list of attributes
 */
public static BinaryAttribute load(DataInputStream in, BinaryConstantPool cpool, int mask) throws IOException {
    BinaryAttribute atts = null;
    int natt = in.readUnsignedShort();  // JVM 4.6 method_info.attrutes_count

    for (int i = 0 ; i < natt ; i++) {
        // id from JVM 4.7 attribute_info.attribute_name_index
        Identifier id = cpool.getIdentifier(in.readUnsignedShort());
        // id from JVM 4.7 attribute_info.attribute_length
        int len = in.readInt();

        if (id.equals(idCode) && ((mask & ATT_CODE) == 0)) {
            in.skipBytes(len);
        } else {
            byte data[] = new byte[len];
            in.readFully(data);
            atts = new BinaryAttribute(id, data, atts);
        }
    }
    return atts;
}
 
源代码5 项目: jdk8u-jdk   文件: BinaryAttribute.java
/**
 * Load a list of attributes
 */
public static BinaryAttribute load(DataInputStream in, BinaryConstantPool cpool, int mask) throws IOException {
    BinaryAttribute atts = null;
    int natt = in.readUnsignedShort();  // JVM 4.6 method_info.attrutes_count

    for (int i = 0 ; i < natt ; i++) {
        // id from JVM 4.7 attribute_info.attribute_name_index
        Identifier id = cpool.getIdentifier(in.readUnsignedShort());
        // id from JVM 4.7 attribute_info.attribute_length
        int len = in.readInt();

        if (id.equals(idCode) && ((mask & ATT_CODE) == 0)) {
            in.skipBytes(len);
        } else {
            byte data[] = new byte[len];
            in.readFully(data);
            atts = new BinaryAttribute(id, data, atts);
        }
    }
    return atts;
}
 
源代码6 项目: jdk8u60   文件: BinaryAttribute.java
/**
 * Load a list of attributes
 */
public static BinaryAttribute load(DataInputStream in, BinaryConstantPool cpool, int mask) throws IOException {
    BinaryAttribute atts = null;
    int natt = in.readUnsignedShort();  // JVM 4.6 method_info.attrutes_count

    for (int i = 0 ; i < natt ; i++) {
        // id from JVM 4.7 attribute_info.attribute_name_index
        Identifier id = cpool.getIdentifier(in.readUnsignedShort());
        // id from JVM 4.7 attribute_info.attribute_length
        int len = in.readInt();

        if (id.equals(idCode) && ((mask & ATT_CODE) == 0)) {
            in.skipBytes(len);
        } else {
            byte data[] = new byte[len];
            in.readFully(data);
            atts = new BinaryAttribute(id, data, atts);
        }
    }
    return atts;
}
 
源代码7 项目: jdk8u-jdk   文件: BinaryAttribute.java
/**
 * Load a list of attributes
 */
public static BinaryAttribute load(DataInputStream in, BinaryConstantPool cpool, int mask) throws IOException {
    BinaryAttribute atts = null;
    int natt = in.readUnsignedShort();  // JVM 4.6 method_info.attrutes_count

    for (int i = 0 ; i < natt ; i++) {
        // id from JVM 4.7 attribute_info.attribute_name_index
        Identifier id = cpool.getIdentifier(in.readUnsignedShort());
        // id from JVM 4.7 attribute_info.attribute_length
        int len = in.readInt();

        if (id.equals(idCode) && ((mask & ATT_CODE) == 0)) {
            in.skipBytes(len);
        } else {
            byte data[] = new byte[len];
            in.readFully(data);
            atts = new BinaryAttribute(id, data, atts);
        }
    }
    return atts;
}
 
源代码8 项目: jdk8u_jdk   文件: BinaryAttribute.java
/**
 * Load a list of attributes
 */
public static BinaryAttribute load(DataInputStream in, BinaryConstantPool cpool, int mask) throws IOException {
    BinaryAttribute atts = null;
    int natt = in.readUnsignedShort();  // JVM 4.6 method_info.attrutes_count

    for (int i = 0 ; i < natt ; i++) {
        // id from JVM 4.7 attribute_info.attribute_name_index
        Identifier id = cpool.getIdentifier(in.readUnsignedShort());
        // id from JVM 4.7 attribute_info.attribute_length
        int len = in.readInt();

        if (id.equals(idCode) && ((mask & ATT_CODE) == 0)) {
            in.skipBytes(len);
        } else {
            byte data[] = new byte[len];
            in.readFully(data);
            atts = new BinaryAttribute(id, data, atts);
        }
    }
    return atts;
}
 
源代码9 项目: openjdk-jdk8u-backup   文件: BinaryAttribute.java
/**
 * Load a list of attributes
 */
public static BinaryAttribute load(DataInputStream in, BinaryConstantPool cpool, int mask) throws IOException {
    BinaryAttribute atts = null;
    int natt = in.readUnsignedShort();  // JVM 4.6 method_info.attrutes_count

    for (int i = 0 ; i < natt ; i++) {
        // id from JVM 4.7 attribute_info.attribute_name_index
        Identifier id = cpool.getIdentifier(in.readUnsignedShort());
        // id from JVM 4.7 attribute_info.attribute_length
        int len = in.readInt();

        if (id.equals(idCode) && ((mask & ATT_CODE) == 0)) {
            in.skipBytes(len);
        } else {
            byte data[] = new byte[len];
            in.readFully(data);
            atts = new BinaryAttribute(id, data, atts);
        }
    }
    return atts;
}
 
源代码10 项目: big-c   文件: ImageLoaderCurrent.java
/**
 * Process the blocks section of the fsimage.
 *
 * @param in Datastream to process
 * @param v Visitor to walk over inodes
 * @param skipBlocks Walk over each block?
 */
private void processBlocks(DataInputStream in, ImageVisitor v,
    int numBlocks, boolean skipBlocks) throws IOException {
  v.visitEnclosingElement(ImageElement.BLOCKS,
                          ImageElement.NUM_BLOCKS, numBlocks);
  
  // directory or symlink or reference node, no blocks to process    
  if(numBlocks < 0) { 
    v.leaveEnclosingElement(); // Blocks
    return;
  }
  
  if(skipBlocks) {
    int bytesToSkip = ((Long.SIZE * 3 /* fields */) / 8 /*bits*/) * numBlocks;
    if(in.skipBytes(bytesToSkip) != bytesToSkip)
      throw new IOException("Error skipping over blocks");
    
  } else {
    for(int j = 0; j < numBlocks; j++) {
      v.visitEnclosingElement(ImageElement.BLOCK);
      v.visit(ImageElement.BLOCK_ID, in.readLong());
      v.visit(ImageElement.NUM_BYTES, in.readLong());
      v.visit(ImageElement.GENERATION_STAMP, in.readLong());
      v.leaveEnclosingElement(); // Block
    }
  }
  v.leaveEnclosingElement(); // Blocks
}
 
/**
 * Reads a COM marker segments and realigns the bit stream at the point
 * where the next marker segment should be found. COM is an informational
 * marker segment that allows to include unstructured data in the main and
 * tile-part headers.
 *
 * @param ehs The encoded header stream
 *
 * @param mainh Flag indicating whether or not this marker segment is read
 * from the main header.
 *
 * @param tileIdx The index of the current tile
 *
 * @param comIdx Occurence of this COM marker in eith main or tile-part
 * header 
 * 
 * @exception IOException If an I/O error occurs while reading from the
 * encoded header stream
 * */
private void readCOM (DataInputStream ehs, boolean mainh, int tileIdx,
                      int comIdx) throws IOException {
    HeaderInfo.COM ms = hi.getNewCOM();

    // Read length of COM field
    ms.lcom = ehs.readUnsignedShort();

    // Read the registration value of the COM marker segment
    ms.rcom = ehs.readUnsignedShort();
    switch(ms.rcom) {
    case RCOM_GEN_USE:
        ms.ccom = new byte[ms.lcom-4];
        for(int i=0; i<ms.lcom-4; i++) {
            ms.ccom[i] = ehs.readByte();
        }
        break;
    default:
        // --- Unknown or unsupported markers ---
        // (skip them and see if we can get way with it)
        FacilityManager.getMsgLogger().
            printmsg(MsgLogger.WARNING,
                     "COM marker registered as 0x"+Integer.
                     toHexString(ms.rcom)+
                     " unknown, ignoring (this might crash the "+
                     "decoder or decode a quality degraded or even "+
                     "useless image)");
        ehs.skipBytes(ms.lcom-4); //Ignore this field for the moment
        break;
    }

    if (mainh) {
        hi.com.put("main_"+comIdx,ms);
    } else {
        hi.com.put("t"+tileIdx+"_"+comIdx,ms);
    }

    // Check marker length
    checkMarkerLength(ehs,"COM marker");
}
 
源代码12 项目: hadoop   文件: ImageLoaderCurrent.java
/**
 * Process the blocks section of the fsimage.
 *
 * @param in Datastream to process
 * @param v Visitor to walk over inodes
 * @param skipBlocks Walk over each block?
 */
private void processBlocks(DataInputStream in, ImageVisitor v,
    int numBlocks, boolean skipBlocks) throws IOException {
  v.visitEnclosingElement(ImageElement.BLOCKS,
                          ImageElement.NUM_BLOCKS, numBlocks);
  
  // directory or symlink or reference node, no blocks to process    
  if(numBlocks < 0) { 
    v.leaveEnclosingElement(); // Blocks
    return;
  }
  
  if(skipBlocks) {
    int bytesToSkip = ((Long.SIZE * 3 /* fields */) / 8 /*bits*/) * numBlocks;
    if(in.skipBytes(bytesToSkip) != bytesToSkip)
      throw new IOException("Error skipping over blocks");
    
  } else {
    for(int j = 0; j < numBlocks; j++) {
      v.visitEnclosingElement(ImageElement.BLOCK);
      v.visit(ImageElement.BLOCK_ID, in.readLong());
      v.visit(ImageElement.NUM_BYTES, in.readLong());
      v.visit(ImageElement.GENERATION_STAMP, in.readLong());
      v.leaveEnclosingElement(); // Block
    }
  }
  v.leaveEnclosingElement(); // Blocks
}
 
源代码13 项目: gravitydefied   文件: Loader.java
private void _hIIV(int j, int k) throws InvalidTrackException {
	try {
		InputStream is = getLevelsInputStream("levels.mrg");
		DataInputStream dis = new DataInputStream(is);
		for (int i1 = pointers[j - 1][k - 1]; i1 > 0; i1 -= dis.skipBytes(i1)) ;
		if (levels == null)
			levels = new Level();
		levels.readTrackData(dis);
		dis.close();
		load(levels);
	} catch (IOException _ex) {
		_ex.printStackTrace();
	}
}
 
/**
    * Reads the PLT fields and realigns the codestream where the next marker
    * should be found. Informations stored in these fields are currently NOT
    * taken into account.
    *
    * @param ehs The encoder header stream.
    *
    * @exception IOException If an I/O error occurs while reading from the
    * encoder header stream
    * */
   private void readPLTFields(DataInputStream ehs) throws IOException{
int length;

length = ehs.readUnsignedShort();
//Ignore all informations contained
ehs.skipBytes(length-2);

       FacilityManager.getMsgLogger().
           printmsg(MsgLogger.INFO,"Skipping unsupported PLT marker");
   }
 
源代码15 项目: rscplus   文件: Util.java
public static int getReplayEnding(File replay) {
  int timestamp_ret = 0;

  try {
    DataInputStream fileInput =
        new DataInputStream(
            new BufferedInputStream(new GZIPInputStream(new FileInputStream(replay))));
    for (; ; ) {
      int timestamp_input = fileInput.readInt();

      // EOF
      if (timestamp_input == -1) break;

      // Skip data, we need to find the last timestamp
      int length = fileInput.readInt();
      if (length > 0) {
        int skipped = fileInput.skipBytes(length);

        if (skipped != length) break;
      }

      timestamp_ret = timestamp_input;
    }
    fileInput.close();
  } catch (Exception e) {
    // e.printStackTrace();
  }

  return timestamp_ret;
}
 
源代码16 项目: cosmic   文件: ServerCutText.java
private void readPacketData(final DataInputStream is) throws IOException {
    is.skipBytes(3);// Skip padding
    final int length = is.readInt();
    final byte[] buf = new byte[length];
    is.readFully(buf);

    content = new String(buf, RfbConstants.CHARSET);

    /* LOG */
    s_logger.info("Clippboard content: " + content);
}
 
源代码17 项目: openjdk-8-source   文件: ICUBinary.java
/**
* <p>ICU data header reader method.
* Takes a ICU generated big-endian input stream, parse the ICU standard
* file header and authenticates them.</p>
* <p>Header format:
* <ul>
*     <li> Header size (char)
*     <li> Magic number 1 (byte)
*     <li> Magic number 2 (byte)
*     <li> Rest of the header size (char)
*     <li> Reserved word (char)
*     <li> Big endian indicator (byte)
*     <li> Character set family indicator (byte)
*     <li> Size of a char (byte) for c++ and c use
*     <li> Reserved byte (byte)
*     <li> Data format identifier (4 bytes), each ICU data has its own
*          identifier to distinguish them. [0] major [1] minor
*                                          [2] milli [3] micro
*     <li> Data version (4 bytes), the change version of the ICU data
*                             [0] major [1] minor [2] milli [3] micro
*     <li> Unicode version (4 bytes) this ICU is based on.
* </ul>
* </p>
* <p>
* Example of use:<br>
* <pre>
* try {
*    FileInputStream input = new FileInputStream(filename);
*    If (Utility.readICUDataHeader(input, dataformat, dataversion,
*                                  unicode) {
*        System.out.println("Verified file header, this is a ICU data file");
*    }
* } catch (IOException e) {
*    System.out.println("This is not a ICU data file");
* }
* </pre>
* </p>
* @param inputStream input stream that contains the ICU data header
* @param dataFormatIDExpected Data format expected. An array of 4 bytes
*                     information about the data format.
*                     E.g. data format ID 1.2.3.4. will became an array of
*                     {1, 2, 3, 4}
* @param authenticate user defined extra data authentication. This value
*                     can be null, if no extra authentication is needed.
* @exception IOException thrown if there is a read error or
*            when header authentication fails.
* @draft 2.1
*/
public static final byte[] readHeader(InputStream inputStream,
                                    byte dataFormatIDExpected[],
                                    Authenticate authenticate)
                                                      throws IOException
{
    DataInputStream input = new DataInputStream(inputStream);
    char headersize = input.readChar();
    int readcount = 2;
    //reading the header format
    byte magic1 = input.readByte();
    readcount ++;
    byte magic2 = input.readByte();
    readcount ++;
    if (magic1 != MAGIC1 || magic2 != MAGIC2) {
        throw new IOException(MAGIC_NUMBER_AUTHENTICATION_FAILED_);
    }

    input.readChar(); // reading size
    readcount += 2;
    input.readChar(); // reading reserved word
    readcount += 2;
    byte bigendian    = input.readByte();
    readcount ++;
    byte charset      = input.readByte();
    readcount ++;
    byte charsize     = input.readByte();
    readcount ++;
    input.readByte(); // reading reserved byte
    readcount ++;

    byte dataFormatID[] = new byte[4];
    input.readFully(dataFormatID);
    readcount += 4;
    byte dataVersion[] = new byte[4];
    input.readFully(dataVersion);
    readcount += 4;
    byte unicodeVersion[] = new byte[4];
    input.readFully(unicodeVersion);
    readcount += 4;
    if (headersize < readcount) {
        throw new IOException("Internal Error: Header size error");
    }
    input.skipBytes(headersize - readcount);

    if (bigendian != BIG_ENDIAN_ || charset != CHAR_SET_
        || charsize != CHAR_SIZE_
        || !Arrays.equals(dataFormatIDExpected, dataFormatID)
        || (authenticate != null
            && !authenticate.isDataVersionAcceptable(dataVersion))) {
        throw new IOException(HEADER_AUTHENTICATION_FAILED_);
    }
    return unicodeVersion;
}
 
源代码18 项目: computoser   文件: SMFTools.java
/**
 * Reads a MIDI track chunk
 *
 * @param DataInputStream
 *            dis - the input stream to read from
 * @exception IOException
 */
private void readTrackChunk(DataInputStream dis) throws IOException {
    // local variables for Track class
    Track track = new Track();
    // Insert new Track into a list of tracks
    this.trackList.addElement(track);
    int deltaTime = 0;
    // Read track header
    if (dis.readInt() != 0x4D54726B) {// If MTrk read is wrong
        throw new IOException("Track started in wrong place!!!!  ABORTING");
    } else {// If MTrk read ok get bytesRemaining
        dis.readInt();
    }
    // loop variables
    int status, oldStatus = 0, eventLength = 0;
    // Start gathering event data
    Event event = null;
    while (true) {
        try {
            // get variable length timestamp
            deltaTime = MidiUtil.readVarLength(dis);
            // mark stream so we can return if we need running status
            dis.mark(2);
            status = dis.readUnsignedByte();
            // decide on running status
            if (status < 0x80) { // set running status
                status = oldStatus;
                // return stream to before status read
                dis.reset();
            }
            // create default event of correct type
            if (status >= 0xFF) { // Meta Event
                int type = dis.readUnsignedByte();
                eventLength = MidiUtil.readVarLength(dis);
                event = jm.midi.MidiUtil.createMetaEvent(type);
            } else if (status >= 0xF0) { // System Exclusive --- NOT
                                         // SUPPORTED
                eventLength = MidiUtil.readVarLength(dis);
            } else if (status >= 0x80) { // MIDI voice event
                short selection = (short) (status / 0x10);
                short midiChannel = (short) (status - (selection * 0x10));
                VoiceEvt evt = (VoiceEvt) MidiUtil.createVoiceEvent(selection);
                if (evt == null) {
                    throw new IOException("MIDI file read error: invalid voice event type!");
                }
                evt.setMidiChannel(midiChannel);
                event = evt;
            }
            oldStatus = status;
        } catch (EOFException ex) {
            logger.warn("EOFException (" + ex.getMessage() + ") encountered in SMFTools");
        } catch (Exception e) {
            throw new IllegalStateException(e);
        }
        if (event != null) {
            // read data into the new event and
            // add the new event to the Track object
            event.setTime(deltaTime);
            event.read(dis);
            track.addEvent(event);
            // event.print();
            if (event instanceof EndTrack)
                break;
        } else {
            // skip the stream ahead to next valid event
            dis.skipBytes(eventLength);
        }
    }
}
 
源代码19 项目: openjdk-jdk8u   文件: ICUBinary.java
/**
* <p>ICU data header reader method.
* Takes a ICU generated big-endian input stream, parse the ICU standard
* file header and authenticates them.</p>
* <p>Header format:
* <ul>
*     <li> Header size (char)
*     <li> Magic number 1 (byte)
*     <li> Magic number 2 (byte)
*     <li> Rest of the header size (char)
*     <li> Reserved word (char)
*     <li> Big endian indicator (byte)
*     <li> Character set family indicator (byte)
*     <li> Size of a char (byte) for c++ and c use
*     <li> Reserved byte (byte)
*     <li> Data format identifier (4 bytes), each ICU data has its own
*          identifier to distinguish them. [0] major [1] minor
*                                          [2] milli [3] micro
*     <li> Data version (4 bytes), the change version of the ICU data
*                             [0] major [1] minor [2] milli [3] micro
*     <li> Unicode version (4 bytes) this ICU is based on.
* </ul>
* </p>
* <p>
* Example of use:<br>
* <pre>
* try {
*    FileInputStream input = new FileInputStream(filename);
*    If (Utility.readICUDataHeader(input, dataformat, dataversion,
*                                  unicode) {
*        System.out.println("Verified file header, this is a ICU data file");
*    }
* } catch (IOException e) {
*    System.out.println("This is not a ICU data file");
* }
* </pre>
* </p>
* @param inputStream input stream that contains the ICU data header
* @param dataFormatIDExpected Data format expected. An array of 4 bytes
*                     information about the data format.
*                     E.g. data format ID 1.2.3.4. will became an array of
*                     {1, 2, 3, 4}
* @param authenticate user defined extra data authentication. This value
*                     can be null, if no extra authentication is needed.
* @exception IOException thrown if there is a read error or
*            when header authentication fails.
* @draft 2.1
*/
public static final byte[] readHeader(InputStream inputStream,
                                    byte dataFormatIDExpected[],
                                    Authenticate authenticate)
                                                      throws IOException
{
    DataInputStream input = new DataInputStream(inputStream);
    char headersize = input.readChar();
    int readcount = 2;
    //reading the header format
    byte magic1 = input.readByte();
    readcount ++;
    byte magic2 = input.readByte();
    readcount ++;
    if (magic1 != MAGIC1 || magic2 != MAGIC2) {
        throw new IOException(MAGIC_NUMBER_AUTHENTICATION_FAILED_);
    }

    input.readChar(); // reading size
    readcount += 2;
    input.readChar(); // reading reserved word
    readcount += 2;
    byte bigendian    = input.readByte();
    readcount ++;
    byte charset      = input.readByte();
    readcount ++;
    byte charsize     = input.readByte();
    readcount ++;
    input.readByte(); // reading reserved byte
    readcount ++;

    byte dataFormatID[] = new byte[4];
    input.readFully(dataFormatID);
    readcount += 4;
    byte dataVersion[] = new byte[4];
    input.readFully(dataVersion);
    readcount += 4;
    byte unicodeVersion[] = new byte[4];
    input.readFully(unicodeVersion);
    readcount += 4;
    if (headersize < readcount) {
        throw new IOException("Internal Error: Header size error");
    }
    input.skipBytes(headersize - readcount);

    if (bigendian != BIG_ENDIAN_ || charset != CHAR_SET_
        || charsize != CHAR_SIZE_
        || !Arrays.equals(dataFormatIDExpected, dataFormatID)
        || (authenticate != null
            && !authenticate.isDataVersionAcceptable(dataVersion))) {
        throw new IOException(HEADER_AUTHENTICATION_FAILED_);
    }
    return unicodeVersion;
}
 
源代码20 项目: cosmic   文件: FramebufferUpdatePacket.java
private void readPacketData(final DataInputStream is) throws IOException {
    is.skipBytes(1);// Skip padding

    // Read number of rectangles
    final int numberOfRectangles = is.readUnsignedShort();

    // For all rectangles
    for (int i = 0; i < numberOfRectangles; i++) {

        // Read coordinate of rectangle
        final int x = is.readUnsignedShort();
        final int y = is.readUnsignedShort();
        final int width = is.readUnsignedShort();
        final int height = is.readUnsignedShort();

        final int encodingType = is.readInt();

        // Process rectangle
        final Rect rect;
        switch (encodingType) {

            case RfbConstants.ENCODING_RAW: {
                rect = new RawRect(this.screen, x, y, width, height, is);
                break;
            }

            case RfbConstants.ENCODING_COPY_RECT: {
                rect = new CopyRect(x, y, width, height, is);
                break;
            }

            case RfbConstants.ENCODING_DESKTOP_SIZE: {
                rect = new FrameBufferSizeChangeRequest(this.canvas, width, height);
                if (this.clientListener != null) {
                    this.clientListener.onFramebufferSizeChange(width, height);
                }
                break;
            }

            default:
                throw new RuntimeException("Unsupported ecnoding: " + encodingType);
        }

        paint(rect, this.canvas);

        if (this.clientListener != null) {
            this.clientListener.onFramebufferUpdate(rect.getX(), rect.getY(), rect.getWidth(), rect.getHeight());
        }
    }
}