Package java.nio

Examples of java.nio.ByteBuffer.order()


          }
         
          final int RESULT_SIZE = (1 + (17 * 4));
         
          ByteBuffer res = ByteBuffer.allocate(RESULT_SIZE);
          res.order(ByteOrder.BIG_ENDIAN);
         
          res.put(FILE_RESP_INFO);
          res.putLong(file_size);
          res.putInt(file_type);
         
View Full Code Here


    if (port == 0) {
      port = fd.getLocalPort();
    }

    ByteBuffer reply = ByteBuffer.allocate(3);
    reply.order(ByteOrder.nativeOrder());
    reply.put(INET_REP_OK);
    reply.putShort((short) (port & 0xFFFF));

    return reply;
  }
View Full Code Here

  protected ByteBuffer control(EPID caller, int command, ByteBuffer out) throws Pausable {
    if (command == CTRL_OP_GET_WINSIZE) {
      // TODO: hmm, how do we do that?
      // for now, we always respond 80x25.
      ByteBuffer bb = ByteBuffer.allocate(8);
      bb.order(ByteOrder.nativeOrder());
      bb.putInt(80);
      bb.putInt(25);
      return bb;
    } else {
      throw ERT.badarg();
View Full Code Here

          : EFile.FT_REGULAR;

      final int RESULT_SIZE = (1 + (29 * 4));

      ByteBuffer res = ByteBuffer.allocate(RESULT_SIZE);
      res.order(ByteOrder.BIG_ENDIAN);

      res.put(EFile.FILE_RESP_INFO);
      res.putLong(file_size);
      res.putInt(file_type);

View Full Code Here

            // Prepares newData to be endian compliant with original buffer
            // data.
            if(audioFormat.getEndian() == AudioFormat.BIG_ENDIAN)
            {
                newData.order(ByteOrder.BIG_ENDIAN);
            }
            else
            {
                newData.order(ByteOrder.LITTLE_ENDIAN);
            }
View Full Code Here

            {
                newData.order(ByteOrder.BIG_ENDIAN);
            }
            else
            {
                newData.order(ByteOrder.LITTLE_ENDIAN);
            }

            // Keeps data unchanged if storeed before the original buffer offset
            // index.
            // Takes care of original data array type (byte, short or int).
View Full Code Here

            iis.close();
        }
        //create a ByteBuffer from the deflated data
        ByteBuffer out = ByteBuffer.wrap( baos.toByteArray() );
        //with proper byte ordering
        out.order( byteOrder );
        return out;
    }
    /**
     * Reads data form byte buffer. Searches for either
     * <code>miCOMPRESSED</code> data or <code>miMATRIX</code> data.
View Full Code Here

public class MarshallersTest extends TestCase {

  private <T> void checkByteOrder(Marshaller<T> m, T value) {
    {
      ByteBuffer buf = m.toBytes(value);
      buf.order(ByteOrder.BIG_ENDIAN);
      assertEquals(value, m.fromBytes(buf));
    }
    {
      ByteBuffer buf2 = m.toBytes(value);
      buf2.order(ByteOrder.LITTLE_ENDIAN);
View Full Code Here

      buf.order(ByteOrder.BIG_ENDIAN);
      assertEquals(value, m.fromBytes(buf));
    }
    {
      ByteBuffer buf2 = m.toBytes(value);
      buf2.order(ByteOrder.LITTLE_ENDIAN);
      assertEquals(value, m.fromBytes(buf2));
    }
  }

  private <T> void checkMoreCapacity(Marshaller<T> m, T value) {
View Full Code Here

            int i = 0;

            while (audioInputStream.read(samplesIn, 0, frameSize) != -1) {
                if (frameSize != 1) {
                    ByteBuffer bb = ByteBuffer.wrap(samplesIn);
                    bb.order(ByteOrder.LITTLE_ENDIAN);
                    short shortVal = bb.getShort();
                    sampleData[i] = shortVal;
                } else {
                    sampleData[i] = samplesIn[0];
                }
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.