Java DataInputStream Read readBytes(DataInputStream stream, int size)

Here you can find the source of readBytes(DataInputStream stream, int size)

Description

read Bytes

License

Open Source License

Declaration

public static byte[] readBytes(DataInputStream stream, int size) throws IOException 

Method Source Code


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

import java.io.DataInputStream;
import java.io.IOException;

public class Main {
    public static byte[] readBytes(DataInputStream stream, int size) throws IOException {
        byte[] buf = new byte[size];
        int toRead = size;
        int done = 0;
        while (toRead > 0) {
            int read = stream.read(buf, done, toRead);
            if (read == -1) {
                throw new IOException();
            }/*from w  w  w.  j av a 2s  . co m*/
            done += read;
            toRead -= read;
        }
        return buf;
    }
}

Related

  1. loadChecksum(Bundle b, BundleContext bc)
  2. loadColorTable(final File file)
  3. loadIntArrayFromFile(File file)
  4. readBytes(DataInputStream dataStream, int numberOfBytes)
  5. readBytes(DataInputStream input, int size)
  6. readBytes(DataInputStream stream, int size)
  7. readBytes(File ff)
  8. readBytes(String filename)
  9. readBytes(String filename)