Java File Read via ByteBuffer readBigEndianWord(byte[] buf)

Here you can find the source of readBigEndianWord(byte[] buf)

Description

read Big Endian Word

License

Open Source License

Declaration

public static short readBigEndianWord(byte[] buf) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.nio.ByteBuffer;
import java.nio.ByteOrder;

public class Main {
    public static short readBigEndianWord(byte[] buf) {
        ByteBuffer bb = ByteBuffer.wrap(buf);
        bb.order(ByteOrder.BIG_ENDIAN);
        if (bb.hasRemaining()) {
            short v = bb.getShort();
            return v;
        }/*  w w  w .ja  va  2s  .co m*/
        return 0;
    }
}

Related

  1. read24BitInteger(byte[] threeBytes, ByteOrder order)
  2. read_file(File input)
  3. readAiffHeader(DataInputStream inStrm, FileChannel fc)
  4. readAndTransfer(final String dir)
  5. readAsByteArray(final InputStream source)
  6. readBinaryFile(File file)
  7. readBinaryFileAsFloats(String fileName)
  8. readByte(String filePath)
  9. readBytes(File f)