Package java.nio

Examples of java.nio.MappedByteBuffer.order()


      FileChannel channel = f.getChannel();
      MappedByteBuffer byteBuf = channel.map(FileChannel.MapMode.READ_ONLY, start, buf.length*4);
      if (bigEndian) {
        byteBuf.order(ByteOrder.BIG_ENDIAN);
      } else {
        byteBuf.order(ByteOrder.LITTLE_ENDIAN);
      }
      while (offset < buf.length) {
        if (components == 3) {
          buf[offset+0] = byteBuf.getFloat();
          buf[offset+1] = byteBuf.getFloat();
View Full Code Here


        FileChannel channel = fileInputStream.getChannel();
        MappedByteBuffer mappedBuffer = fileInputStream.getChannel().map(
                MapMode.READ_ONLY,
                0,
                channel.size());
        mappedBuffer.order(ByteOrder.LITTLE_ENDIAN);
        return mappedBuffer;
    }
}
View Full Code Here

                throw new IllegalStateException("map failed for page#" + page + " of file: "
                        + _filepath, ioe);
            }
        }
        if(_setAsLittleEndian) {// BIG_ENDIAN by the default
            buf.order(ByteOrder.LITTLE_ENDIAN);
        }
        return buf;
    }

    public int[] transferBuffer(final long pageOffset, final int aryLength) {
View Full Code Here

  }

  private void read(FileInputStream is) throws IOException {
    FileChannel fc = is.getChannel();
    MappedByteBuffer bbuf = fc.map(MapMode.READ_ONLY, 0, fc.size());
    bbuf.order(ByteOrder.LITTLE_ENDIAN);
    int magic = bbuf.getInt()
    if (magic == 0x0B17C0DE)
    {
      int version = bbuf.getInt();
      int ofs = bbuf.getInt();
View Full Code Here

    try(RandomAccessFile raf = new RandomAccessFile(geoFile, "r");
        FileChannel roChannel = raf.getChannel())
    {
      long size = roChannel.size();
      MappedByteBuffer buf = roChannel.map(FileChannel.MapMode.READ_ONLY, 0, size);
      buf.order(ByteOrder.LITTLE_ENDIAN);
      rawgeo[ix][iy] = buf;
      if (size < (BLOCKS_IN_MAP * 3))
      {
        throw new RuntimeException("Invalid geodata : " + fname + "!");
      }
View Full Code Here

        final MappedByteBuffer buf;
        try {
            final RandomAccessFile raf = new RandomAccessFile(tileMetricsOut, "rw");
            final FileChannel channel = raf.getChannel();
            buf = channel.map(FileChannel.MapMode.READ_WRITE, 0, 2 + 10 * totalEntries);
            buf.order(ByteOrder.LITTLE_ENDIAN);

            buf.put(versionNumber);
            buf.put(recordSize);

            for (final int lane : lanesToTiles.keySet()) {
View Full Code Here

    /** Ecma 335, 25 File format extensions to PE:
     *
     *  "Unless stated otherwise, all binary values are stored in little-endian format."
     */

  bb.order(java.nio.ByteOrder.LITTLE_ENDIAN);
  this.buf = bb;

    /** Ecma 335, 25.2.1 MS-DOS header:
     *
     *  "The PE format starts with an MS-DOS stub of exactly the following 128 bytes to
View Full Code Here

     */
    public MappedByteBuffer mapBuffer(long offset, int size) {
   try {
      MappedByteBuffer b = file.getChannel()
    .map(FileChannel.MapMode.READ_ONLY, offset, size);
      b.order(java.nio.ByteOrder.LITTLE_ENDIAN);
      return b;
   } catch (IOException e) { throw new RuntimeException(e); }
    }

    /** Returns a buffer from the given offset to the end of the file. */
 
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.