Package java.nio

Examples of java.nio.ByteBuffer.array()


        ByteBuffer buf=ByteBuffer.allocate(SIZE);
        buf.put(type);
        buf.putInt(x);
        buf.putInt(y);
        buf.putInt(val);
        return buf.array();
    }

    public void init(ByteBuffer buf) {
        type=buf.get();
        x=buf.getInt();
View Full Code Here


    if (read == -1) {  // EOF
      reachedEOF = true;
      IOLoop.INSTANCE.updateHandler(channel, interestOps &= ~SelectionKey.OP_READ);
      return;
    }
    readBuffer.append(new String(buffer.array(), 0, buffer.position(), Charsets.ISO_8859_1));
    logger.debug("readBuffer size: {}", readBuffer.length());
    checkReadState();
  }

  /**
 
View Full Code Here


    private static byte[] createPayload(int size, int seqno) {
        ByteBuffer buf=ByteBuffer.allocate(size);
        buf.putInt(seqno);
        return buf.array();
    }


    /** Checks that messages 1 - NUM_MSGS are received in order */
    static class Receiver implements Simulator.Receiver {
View Full Code Here

            load_from_file(szUnicharFile);
            loadPffmTable(szPfmTable);
            FileInputStream fis = new FileInputStream(szIntTempFile);
            ByteBuffer bb = ByteBuffer.allocate(nIntByteSize * 3);
            ByteOrder bo = ByteOrder.BIG_ENDIAN;
            fis.read(bb.array());
            IntBuffer ib = bb.asIntBuffer();
            boolean swap = (ib.get(2) < 0 || ib.get(2) > MAX_NUM_CLASS_PRUNERS);
            if (swap) {
                bo = ByteOrder.LITTLE_ENDIAN;
                bb.order(bo);
View Full Code Here

            int NumClassPruners = ib.get(2);
            int version_id = 0;
            if (NumClasses < 0) {
                // handle version id
                version_id = -NumClasses;
                fis.read(bb.array(), 0, 4);
                NumClasses = ib.get(0);
            }   
            //this.ClassPruner.ensureCapacity(NumClassPruners);
            bb = ByteBuffer.allocate(nShortByteSize * unicharset_size);
            bb.order(bo);
View Full Code Here

                NumClasses = ib.get(0);
            }   
            //this.ClassPruner.ensureCapacity(NumClassPruners);
            bb = ByteBuffer.allocate(nShortByteSize * unicharset_size);
            bb.order(bo);
            fis.read(bb.array());
            ShortBuffer sb = bb.asShortBuffer();
            for (int i=0; i<unicharset_size; i++) {
                this.IndexFor[i] = sb.get(i);
            }
            bb = ByteBuffer.allocate(nIntByteSize * NumClasses);
 
View Full Code Here

            for (int i=0; i<unicharset_size; i++) {
                this.IndexFor[i] = sb.get(i);
            }
            bb = ByteBuffer.allocate(nIntByteSize * NumClasses);
            bb.order(bo);
            fis.read(bb.array());
            ib = bb.asIntBuffer();
            for (int i=0; i<NumClasses; i++) {
                this.ClassIdFor[i] = ib.get(i);
            }
            ArrayList<byte[][][][]> ClassPruners = new ArrayList<byte[][][][]>();
View Full Code Here

                byte[][][][] Pruner =
                        new byte[NUM_CP_BUCKETS][NUM_CP_BUCKETS][NUM_CP_BUCKETS][];
                bb = ByteBuffer.allocate(nIntByteSize * NUM_CP_BUCKETS *
                        NUM_CP_BUCKETS * NUM_CP_BUCKETS * WERDS_PER_CP_VECTOR);
                bb.order(bo);
                fis.read(bb.array());
                ib = bb.asIntBuffer();
                int p = 0;
                for (int j=0; j<NUM_CP_BUCKETS; j++) {
                    for (int k=0; k<NUM_CP_BUCKETS; k++) {
                        for (int l=0; l<NUM_CP_BUCKETS; l++) {
View Full Code Here

        try {
            final int nIntByteSize = Integer.SIZE / Byte.SIZE;
            ByteBuffer bb = ByteBuffer.allocate(4 +
                    nIntByteSize * WERDS_PER_CONFIG_VEC);
            bb.order(bo);
            fis.read(bb.array());
            this.A = bb.get(0) << 1;
            // Java doesn't have unsigned byte
            this.B = unsignedByteToShort(bb.get(1));
            this.C = bb.get(2) << 9;
            this.Angle = unsignedByteToShort(bb.get(3));
View Full Code Here

                    terminate=true;

                if(buf.remaining() == 0 || terminate) {
                    if(body == null) {
                        body=new byte[buf.position()];
                        System.arraycopy(buf.array(), buf.arrayOffset(), body, 0, buf.position());
                    }
                    else {
                        byte[] tmp=new byte[body.length + buf.position()];
                        System.arraycopy(body, 0, tmp, 0, body.length);
                        try {
View Full Code Here

TOP
Copyright © 2015 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.