Package java.nio

Examples of java.nio.ByteBuffer.flip()


    byte[] headBytes = keyStr.getBytes();
    byte[] passBytes = ConvertHelper.hexString2ByteNoSpace(this.encryptedpass.substring(8));
    ByteBuffer buffer = ByteBuffer.allocate(headBytes.length+passBytes.length);
    buffer.put(headBytes);
    buffer.put(passBytes);
    buffer.flip();
   
    return DigestHelper.SHA1(buffer.array());
  }
 
  /**
 
View Full Code Here


    byte[] cryptedBytes = DigestHelper.SHA1(plainpass.getBytes());
   
    ByteBuffer buffer  = ByteBuffer.allocate(saltBytes.length+cryptedBytes.length);
    buffer.put(saltBytes);
    buffer.put(cryptedBytes);
    buffer.flip();
   
    cryptedBytes = DigestHelper.SHA1(buffer.array());
   
    buffer.clear();
    buffer.put(saltBytes);
View Full Code Here

        inBuffer.clear();
        ownerAcceptor.getConfigure().getIoHandler().messageReceived(this, msgdata);
      }
      else //当设置了协议处理者时
        ByteBuffer readBuf = inBuffer.asReadOnlyBuffer();
        readBuf.flip();

        List<NetMessage> list = ownerAcceptor.getConfigure().getProtocolHandler().onData(readBuf, this);

        //TODO:如果得到错误消息,应该立即终止读取,并关闭Session
       
View Full Code Here

   * @param b   the byte
   * @return the ByteBuffer which contains the single byte
   */
  public static ByteBuffer toByteBuffer(byte b) {
    ByteBuffer buffer = ByteBuffer.allocate(1).put(b);
    buffer.flip();
   
    return buffer;
  }
 
 
View Full Code Here

   * @param d   the double
   * @return the ByteBuffer which contains the double
   */
  public static ByteBuffer toByteBuffer(double d) {
    ByteBuffer buffer = ByteBuffer.allocate(8).putDouble(d);
    buffer.flip();
   
    return buffer;
  }
 
 
View Full Code Here

   * @param l   the long
   * @return the ByteBuffer which contains the long
   */
  public static ByteBuffer toByteBuffer(long l) {
    ByteBuffer buffer = ByteBuffer.allocate(8).putLong(l);
    buffer.flip();
   
    return buffer;
  }
 

View Full Code Here

   * @param s   the short
   * @return the ByteBuffer which contains the short
   */
  public static ByteBuffer toByteBuffer(short s) {
    ByteBuffer buffer = ByteBuffer.allocate(2).putShort(s);
    buffer.flip();
   
    return buffer;
  }
 

View Full Code Here

   * @param i   the int
   * @return the ByteBuffer which contains the int
   */
  public static ByteBuffer toByteBuffer(int i) {
    ByteBuffer buffer = ByteBuffer.allocate(4).putInt(i);
    buffer.flip();
   
    return buffer;
  }
 
 
View Full Code Here

        ByteBuffer buffer = ByteBuffer.allocate((int) fc.size());
        fc.read(buffer);
        fc.close();
        raf.close();
        buffer.flip();
       
        // add part
        addPart(DataConverter.toByteBuffer(header), buffer);
  }
   
View Full Code Here

                    bufferSize = MAX_BUFFER_SIZE;
                }
               
                ByteBuffer buf = ByteBuffer.allocate(bufferSize);
                fc.read(buf);
                buf.flip();
                read += buf.remaining();

                if (LOG.isLoggable(Level.FINE)) {
                    LOG.fine(buf.remaining() + " bytes read from " + file.getAbsolutePath());
                }
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.