Java Utililty Methods DataInputStream Read

List of utility methods to do DataInputStream Read

Description

The list of methods to do DataInputStream Read are organized into topic(s).

Method

longloadChecksum(Bundle b, BundleContext bc)
Returns the stored checksum of the bundle.
String key = getBundleKey(b);
File f = bc.getDataFile(key + CHECKSUM_SUFFIX);
DataInputStream in = null;
try {
    in = new DataInputStream(new FileInputStream(f));
    return in.readLong();
} catch (Exception e) {
    return Long.MIN_VALUE;
...
float[][]loadColorTable(final File file)
Loads the color table from the given file.
if (file == null || !file.exists())
    return null;
final long fileLen = file.length();
if (fileLen > Integer.MAX_VALUE)
    return null;
final int offset = (int) fileLen - LUT_LEN;
if (offset < 0)
    return null;
...
int[]loadIntArrayFromFile(File file)
load Int Array From File
if (!file.exists()) {
    return null;
int size = (int) (file.length() / 4l);
DataInputStream dis = null;
try {
    dis = new DataInputStream(new FileInputStream(file));
    int[] array = new int[size];
...
StringreadBytes(DataInputStream dataStream, int numberOfBytes)
read Bytes
String temp = "";
for (int i = 0; i < numberOfBytes; i++) {
    char c = (char) dataStream.readByte();
    temp += c;
return temp;
byte[]readBytes(DataInputStream input, int size)
Reads exact amount of bytes
if (input == null)
    return null;
byte bytes[] = new byte[size];
int numRead = 0;
while (numRead < size) {
    int ret = input.read(bytes, numRead, size - numRead);
    if (ret < 0)
        throw new IOException("EOF");
...
byte[]readBytes(DataInputStream stream, int size)
read Bytes
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();
    done += read;
    toRead -= read;
return buf;
byte[]readBytes(DataInputStream stream, int size)
Read a number of bytes or throw.
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();
    done += read;
    toRead -= read;
return buf;
byte[]readBytes(File ff)
read Bytes
byte b[] = new byte[(int) ff.length()];
DataInputStream din = new DataInputStream(new FileInputStream(ff));
try {
    din.readFully(b);
} finally {
    din.close();
return b;
...
byte[]readBytes(String filename)
read Bytes
File file = new File(filename);
FileInputStream fileInputStream = new FileInputStream(file);
DataInputStream dataInputStream = new DataInputStream(fileInputStream);
try {
    byte[] keyBytes = new byte[(int) file.length()];
    dataInputStream.readFully(keyBytes);
    return keyBytes;
} finally {
...
byte[]readBytes(String filename)
read Bytes
File fileTxt = new File(filename);
if (!fileTxt.exists()) {
    System.out.println("Erro ao abrir arquivo:\n" + fileTxt.getAbsolutePath());
    return null;
try {
    int size = (int) fileTxt.length();
    byte[] bytes = new byte[size];
...