Package java.nio

Examples of java.nio.ByteBuffer.array()


                    }
                    else {
                        byte[] tmp=new byte[body.length + buf.position()];
                        System.arraycopy(body, 0, tmp, 0, body.length);
                        try {
                            System.arraycopy(buf.array(), buf.arrayOffset(), tmp, body.length, buf.position());
                        }
                        catch(Throwable t) {
                        }
                        body=tmp;
                    }
View Full Code Here


                    target_connections.addAll(conns);
            }
        }

        for(Connection conn: target_connections)
            conn.writeResponse(buf.array(), buf.arrayOffset(), buf.position());
    }


    /**
     * Class which handles a connection to a client
View Full Code Here

    try {
      final int nIntByteSize = Integer.SIZE / Byte.SIZE;
      final int nShortByteSize = Short.SIZE / Byte.SIZE;
      ByteBuffer bb = ByteBuffer.allocate(nShortByteSize + 2);
      bb.order(bo);
      fis.read(bb.array());
      this.NumProtos = bb.getShort(0);
      short NumProtoSets = LearntFeature.unsignedByteToShort(bb
          .get(nShortByteSize));
      this.NumConfigs = LearntFeature.unsignedByteToShort(bb
          .get(nShortByteSize + 1));
View Full Code Here

          .get(nShortByteSize + 1));
      if (nVersionId == 0) {
        // Only version 0 writes 5 pointless pointers to the file.
        // skip 5 ints
        bb = ByteBuffer.allocate(5 * nIntByteSize);
        fis.read(bb.array());
      }
      bb = ByteBuffer.allocate(MAX_NUM_CONFIGS * nShortByteSize);
      bb.order(bo);
      fis.read(bb.array());
      ShortBuffer sb = bb.asShortBuffer();
View Full Code Here

        bb = ByteBuffer.allocate(5 * nIntByteSize);
        fis.read(bb.array());
      }
      bb = ByteBuffer.allocate(MAX_NUM_CONFIGS * nShortByteSize);
      bb.order(bo);
      fis.read(bb.array());
      ShortBuffer sb = bb.asShortBuffer();
      for (int i = 0; i < this.ConfigLengths.length; i++) {
        this.ConfigLengths[i] = sb.get(i);
      }
      this.ProtoLengths = new short[NumProtoSets
View Full Code Here

          * Prototype.PROTOS_PER_PROTO_SET];
      Arrays.fill(this.ProtoLengths, (short) 0);
      bb = ByteBuffer.allocate(NumProtoSets
          * Prototype.PROTOS_PER_PROTO_SET);
      bb.order(bo);
      fis.read(bb.array());
      for (int i = 0; i < this.NumProtos; i++) {
        this.ProtoLengths[i] = LearntFeature.unsignedByteToShort(bb.get(i));
      }
      int nProtosLeft = this.NumProtos;
      for (int i = 0; i < NumProtoSets; i++) {
View Full Code Here

        try {
            final int nIntByteSize = Integer.SIZE / Byte.SIZE;
            ByteBuffer bb = ByteBuffer.allocate(nIntByteSize * NUM_PP_PARAMS *
                    NUM_PP_BUCKETS * WERDS_PER_PP_VECTOR);
            bb.order(bo);
            fis.read(bb.array());
            IntBuffer ib = bb.asIntBuffer();
            int p = 0;
            for (int i=0; i<NUM_PP_PARAMS; i++) {
                for (int j=0; j<NUM_PP_BUCKETS; j++) {
                    for (int k=0; k<WERDS_PER_PP_VECTOR; k++) {
View Full Code Here

      try {
        byte[] bytes;
        ByteBuffer byteBuffer= encoder.encode(CharBuffer.wrap(document.get()));
        if (byteBuffer.hasArray())
          bytes= byteBuffer.array();
        else {
          bytes= new byte[byteBuffer.limit()];
          byteBuffer.get(bytes);
        }
        stream= new ByteArrayInputStream(bytes, 0, byteBuffer.limit());
View Full Code Here

    long crc = crc(buffer);
    buffer.limit(length + 12);
    buffer.putInt((int)crc);
   
    buffer.position(0);
    return buffer.array();
   
  }
 
  public abstract byte[] getContentPayload();
View Full Code Here

    buffer.put(ihdr);
    buffer.put(idat);
    buffer.put(iend);
   
    buffer.position(0);
    return buffer.array();
  }
 
  public static void main(String args[]) throws Exception {
    File test = new File("/Users/olivier/Desktop/test.png");
    FileOutputStream fos = new FileOutputStream(test);
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.