Java File Read via ByteBuffer readInt(ByteArrayInputStream bin)

Here you can find the source of readInt(ByteArrayInputStream bin)

Description

Reads the next 4 bytes from the stream as integer.

License

Open Source License

Declaration

public static int readInt(ByteArrayInputStream bin) throws IOException 

Method Source Code


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

import java.io.ByteArrayInputStream;

import java.io.IOException;
import java.nio.ByteBuffer;

public class Main {
    /**//from w w w  .j a v a  2s .c o  m
     * Reads the next 4 bytes from the stream as integer.
     */
    public static int readInt(ByteArrayInputStream bin) throws IOException {
        byte[] buffer = new byte[4];
        bin.read(buffer);
        return ByteBuffer.wrap(buffer).getInt();
    }
}

Related

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