Java File Read via ByteBuffer readShort(DataInput input)

Here you can find the source of readShort(DataInput input)

Description

read Short

License

Open Source License

Declaration

private static short readShort(DataInput input) throws IOException 

Method Source Code


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

import java.io.*;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;

public class Main {
    private static short readShort(DataInput input) throws IOException {
        byte[] buf = new byte[2];
        input.readFully(buf);//from www .j av  a2 s .  c  om
        ByteBuffer bb = ByteBuffer.wrap(buf).order(ByteOrder.LITTLE_ENDIAN);
        return bb.getShort(0);
    }
}

Related

  1. readLong(RandomAccessFile raFile)
  2. readLTriad(byte[] triad)
  3. readNByte(ReadableByteChannel channel, int n)
  4. readNIOFile(String filePath)
  5. readShort(byte[] bytes, int start)
  6. readShortBuffer(DataInputStream input)
  7. readShortByteArray(DataInput in)
  8. readString(ByteArrayInputStream bin)
  9. readString(ReadableByteChannel channel)