Package java.nio

Examples of java.nio.ByteBuffer.remaining()


      // Verify file header
      ByteBuffer buf = ByteBuffer.allocate((int)HEADER_LENGTH);
      fileChannel.read(buf, 0L);
      buf.rewind();

      if (buf.remaining() < HEADER_LENGTH) {
        throw new IOException("File too short to be a compatible ID file");
      }

      byte[] magicNumber = new byte[MAGIC_NUMBER.length];
      buf.get(magicNumber);
View Full Code Here


      // Verify file header
      ByteBuffer buf = ByteBuffer.allocate((int)HEADER_LENGTH);
      fileChannel.read(buf, 0L);
      buf.rewind();

      if (buf.remaining() < HEADER_LENGTH) {
        throw new IOException("File too short to be a compatible data file");
      }

      byte[] magicNumber = new byte[MAGIC_NUMBER.length];
      buf.get(magicNumber);
View Full Code Here

  private void writeString(String s, DataOutputStream dataOut)
    throws IOException
  {
    ByteBuffer byteBuf = charsetEncoder.encode(CharBuffer.wrap(s));
    dataOut.writeInt(byteBuf.remaining());
    dataOut.write(byteBuf.array(), 0, byteBuf.remaining());
  }

  private String readString(DataInputStream dataIn)
    throws IOException
View Full Code Here

  private void writeString(String s, DataOutputStream dataOut)
    throws IOException
  {
    ByteBuffer byteBuf = charsetEncoder.encode(CharBuffer.wrap(s));
    dataOut.writeInt(byteBuf.remaining());
    dataOut.write(byteBuf.array(), 0, byteBuf.remaining());
  }

  private String readString(DataInputStream dataIn)
    throws IOException
  {
View Full Code Here

    do {
      ByteBuffer transferBuffer = ByteBuffer.allocate(chunkSize);
      read = bodyDatasource.read(transferBuffer);

      if (read > 0) {
        if (transferBuffer.remaining() == 0) {
          transferBuffer.flip();
          buffers.add(transferBuffer);

        } else {
          transferBuffer.flip();
View Full Code Here

   
    int read = 0;
   
    for (int i = bufferIdx; i < buffers.size(); i++) {
      ByteBuffer buffer = buffers.get(i);
      read += buffer.remaining();
     
      bufferSink.add(buffer);
    }
   
    clear();
View Full Code Here

     
      byte cmdtype = contentbuf.get();
      long playerId = contentbuf.getLong();
      int validateCode = contentbuf.getInt();
     
      byte[] body = new byte[contentbuf.remaining()];
      contentbuf.get(body);
     
      InputMessage msg = new InputMessage(cmdtype, playerId, validateCode, body);
     
      if(list == null) {
View Full Code Here

     
      byte cmdtype = contentBuffer.get();
      long playerId = contentBuffer.getLong();
      int validateCode = contentBuffer.getInt();
     
      byte[] msgbody = new byte[contentBuffer.remaining()];
     
      contentBuffer.get(msgbody);
     
      InputMessage msg = new InputMessage(cmdtype,playerId, validateCode, msgbody);
     
View Full Code Here

  private void writeString(String s)
    throws IOException
  {
    ByteBuffer byteBuf = charsetEncoder.encode(CharBuffer.wrap(s));
    out.writeInt(byteBuf.remaining());
    out.write(byteBuf.array(), 0, byteBuf.remaining());
  }
}
View Full Code Here

  private void writeString(String s)
    throws IOException
  {
    ByteBuffer byteBuf = charsetEncoder.encode(CharBuffer.wrap(s));
    out.writeInt(byteBuf.remaining());
    out.write(byteBuf.array(), 0, byteBuf.remaining());
  }
}
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.