Package java.nio

Examples of java.nio.ByteBuffer.order()


     * with LittleInidan order
     */
    @Test
    public void testGetInt2Ints2BBsLittleIndian() {
        ByteBuffer bb1 = ByteBuffer.allocate(4);
        bb1.order(ByteOrder.LITTLE_ENDIAN);
        bb1.putInt(12345);
        bb1.flip();

        ByteBuffer bb2 = ByteBuffer.allocate(4);
        bb2.order(ByteOrder.LITTLE_ENDIAN);
View Full Code Here


        bb1.order(ByteOrder.LITTLE_ENDIAN);
        bb1.putInt(12345);
        bb1.flip();

        ByteBuffer bb2 = ByteBuffer.allocate(4);
        bb2.order(ByteOrder.LITTLE_ENDIAN);
        bb2.putInt(67890);
        bb2.flip();

        IoBuffer ioBuffer = IoBuffer.wrap(bb1, bb2);
        ioBuffer.order(ByteOrder.LITTLE_ENDIAN);
View Full Code Here

    {
        check(block.getId()) ;
        ByteBuffer bb = block.getByteBuffer() ;
        if ( bb.capacity() != blockSize )
            throw new BlockException(format("BlockMgrFile: Wrong size block.  Expected=%d : actual=%d", blockSize, bb.capacity())) ;
        if ( bb.order() != SystemTDB.NetworkOrder )
            throw new BlockException("BlockMgrFile: Wrong byte order") ;
    }

    protected void force()
    {
View Full Code Here

    public static void main(String[] args) throws IOException {
        File file = new File("swiss_roll_data.matlab5");
        FileChannel channel = new FileInputStream(file).getChannel();
        ByteBuffer scan = channel.map(MapMode.READ_ONLY,0,channel.size());
        scan.order(ByteOrder.BIG_ENDIAN);
        /*
         * MATLAB Version 5 MAT-files begin with a 128-byte header made up of a
         * 124 byte text field and two, 16-bit flag fields. <P> The first 124
         * bytes of the header can contain text data in human-readable form.
         * This text typically provides information that describes how the
View Full Code Here

         */
        short version = scan.getShort();
        System.out.println(version);
        short letters = scan.getShort();
        char shouldBeM = (char) (letters >> 8);
        if (shouldBeM == 'I') scan.order(ByteOrder.LITTLE_ENDIAN);
           
        /* Data Element Format
Each data element begins with an 8-byte tag followed immediately by the data
in the element. Figure2 shows this format. (MATLAB also supports a
compressed data element format. See page -9 for more information.)
View Full Code Here

     * @return Returns said byte sequence.
     */
    private static byte[] encodeTrialLicense( long startTime ) {
        final byte[] buf = new byte[ TRIAL_LICENSE_SIZE ];
        final ByteBuffer bb = ByteBuffer.wrap( buf );
        bb.order( ByteOrder.nativeOrder() );
        bb.put( (byte)'T' );
        bb.putInt( (int)startTime );
        bb.putShort( (short)Version.getRevisionNumber() );
        return buf;
    }
View Full Code Here

            m_nextEXIFBigValuePos += EXIF_HEADER_SIZE;
            m_endPosPlus1 += EXIF_HEADER_SIZE;
        }
        final ByteBuffer buf = ByteBuffer.allocate( m_endPosPlus1 );
        final ByteOrder nativeOrder = ByteOrder.nativeOrder();
        buf.order( nativeOrder );
        if ( m_includeHeader ) {
            ByteBufferUtil.put( buf, "Exif\0\0", "ASCII" );
            buf.putShort(
                nativeOrder == ByteOrder.BIG_ENDIAN ?
                    TIFF_BIG_ENDIAN : TIFF_LITTLE_ENDIAN
View Full Code Here

                System.err.println( "  trial license" );
                switch ( buf.length ) {

                    case TRIAL_LICENSE_SIZE:
                        final ByteBuffer bb = ByteBuffer.wrap( buf );
                        bb.order( ByteOrder.nativeOrder() );
                        bb.get();   // skip 'T'
                        m_trialLicenseStart = bb.getInt();

                        m_licenseType = LICENSE_TRIAL;
                        break;
View Full Code Here

    /**
     * {@inheritDoc}
     */
    public ByteBuffer getByteBuffer( int size ) {
        final ByteBuffer buf = ByteBuffer.allocate( size );
        buf.order( ByteOrder.nativeOrder() );
        return buf;
    }

    /**
     * {@inheritDoc}
 
View Full Code Here

                                      FreeBlockManager fbm ) {
        final CacheBlock block = fbm.findBlockOfSize( size );
        if ( block != null ) {
            final long addr = chunk.getAddr() + block.getPosition();
            final ByteBuffer buf = getNativeByteBuffer( addr, size );
            buf.order( ByteOrder.nativeOrder() );
            final Long bufKey = getKeyFor( buf );
            m_allocdBlocks.put( bufKey, block );
            m_allocdFBMs.put( bufKey, fbm );
            return buf;
        }
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.