Java File Read via ByteBuffer readInt(byte[] in)

Here you can find the source of readInt(byte[] in)

Description

read Int

License

Open Source License

Declaration

public static int readInt(byte[] in) 

Method Source Code

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

import java.io.IOException;
import java.io.InputStream;

import java.nio.ByteBuffer;

public class Main {
    public static int readInt(InputStream in) throws IOException {
        return ByteBuffer.wrap(readByteArray(Integer.BYTES, in)).getInt();
    }// w w w .  ja va  2s  .c  om

    public static int readInt(byte[] in) {
        return ByteBuffer.wrap(in).getInt();
    }

    public static byte[] readByteArray(int length, InputStream in) throws IOException {
        byte[] b = new byte[length];
        in.read(b);
        return b;
    }
}

Related

  1. readHeaderArea(InputStream in)
  2. readInputStream(InputStream input)
  3. readInputStreamToString(InputStream inputStream)
  4. readInt(byte[] bytes, int index)
  5. readInt(byte[] bytes, int offset, java.nio.ByteOrder byteorder)
  6. readInt(ByteArrayInputStream bin)
  7. readInt(InputStream in, ByteOrder order)
  8. readInt(InputStream input)
  9. readInt(InputStream inputStream)