PenProfile 2.x

com.livescribe.io
Class FastIOHelper

java.lang.Object
  extended by com.livescribe.io.FastIOHelper

public class FastIOHelper
extends Object

A native-backed helper class that quickly reads primitive types into an array from an InputStream. Read times for large arrays are dramatically reduced by the use of this class. In other words, using this is faster than doing byte manipulation yourself.

Note that only streams retrieved from Class.getResourceAsStream(String) will use the fast way. The methods here will default to the slower way if any other stream types are used.


Method Summary
static void readFully(InputStream in, boolean[] data)
          Reads boolean data from the given input stream into the specified boolean array.
static void readFully(InputStream in, boolean[] data, int off, int len)
          Reads boolean data from the given input stream into the specified boolean array.
static void readFully(InputStream in, char[] data)
          Reads char data from the given input stream into the specified char array.
static void readFully(InputStream in, char[] data, int off, int len)
          Reads char data from the given input stream into the specified char array.
static void readFully(InputStream in, int[] data)
          Reads int data from the given input stream into the specified int array.
static void readFully(InputStream in, int[] data, int off, int len)
          Reads int data from the given input stream into the specified int array.
static void readFully(InputStream in, long[] data)
          Reads long data from the given input stream into the specified long array.
static void readFully(InputStream in, long[] data, int off, int len)
          Reads long data from the given input stream into the specified long array.
static void readFully(InputStream in, short[] data)
          Reads short data from the given input stream into the specified short array.
static void readFully(InputStream in, short[] data, int off, int len)
          Reads short data from the given input stream into the specified short array.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

readFully

public static void readFully(InputStream in,
                             char[] data)
                      throws IOException
Reads char data from the given input stream into the specified char array. This will try to read data until the array is filled. This is the same as calling read(in, data, 0, data.length.

Parameters:
in - the input stream
data - read into this array
Throws:
IOException - if there was an I/O error while reading.
EOFException - if the entire array could not be read.

readFully

public static void readFully(InputStream in,
                             char[] data,
                             int off,
                             int len)
                      throws IOException
Reads char data from the given input stream into the specified char array. This will try to read exactly len elements.

Parameters:
in - the input stream
data - read into this array
off - offset into the array
len - read this number of elements
Throws:
IOException - if there was an I/O error while reading.
EOFException - if the specified number of elements could not be read.
IndexOutOfBoundsException - if the parameters are out of range.

readFully

public static void readFully(InputStream in,
                             int[] data)
                      throws IOException
Reads int data from the given input stream into the specified int array. This will try to read data until the array is filled. This is the same as calling read(in, data, 0, data.length.

Parameters:
in - the input stream
data - read into this array
Throws:
IOException - if there was an I/O error while reading.
EOFException - if the entire array could not be read.

readFully

public static void readFully(InputStream in,
                             int[] data,
                             int off,
                             int len)
                      throws IOException
Reads int data from the given input stream into the specified int array. This will try to read exactly len elements.

Parameters:
in - the input stream
data - read into this array
off - offset into the array
len - read this number of elements
Throws:
IOException - if there was an I/O error while reading.
EOFException - if the specified number of elements could not be read.
IndexOutOfBoundsException - if the parameters are out of range.

readFully

public static void readFully(InputStream in,
                             short[] data)
                      throws IOException
Reads short data from the given input stream into the specified short array. This will try to read data until the array is filled. This is the same as calling read(in, data, 0, data.length.

Parameters:
in - the input stream
data - read into this array
Throws:
IOException - if there was an I/O error while reading.
EOFException - if the entire array could not be read.

readFully

public static void readFully(InputStream in,
                             short[] data,
                             int off,
                             int len)
                      throws IOException
Reads short data from the given input stream into the specified short array. This will try to read exactly len elements.

Parameters:
in - the input stream
data - read into this array
off - offset into the array
len - read this number of elements
Throws:
IOException - if there was an I/O error while reading.
EOFException - if the specified number of elements could not be read.
IndexOutOfBoundsException - if the parameters are out of range.

readFully

public static void readFully(InputStream in,
                             boolean[] data)
                      throws IOException
Reads boolean data from the given input stream into the specified boolean array. This will try to read data until the array is filled. This is the same as calling read(in, data, 0, data.length.

Parameters:
in - the input stream
data - read into this array
Throws:
IOException - if there was an I/O error while reading.
EOFException - if the entire array could not be read.

readFully

public static void readFully(InputStream in,
                             boolean[] data,
                             int off,
                             int len)
                      throws IOException
Reads boolean data from the given input stream into the specified boolean array. This will try to read exactly len elements.

Parameters:
in - the input stream
data - read into this array
off - offset into the array
len - read this number of elements
Throws:
IOException - if there was an I/O error while reading.
EOFException - if the specified number of elements could not be read.
IndexOutOfBoundsException - if the parameters are out of range.

readFully

public static void readFully(InputStream in,
                             long[] data)
                      throws IOException
Reads long data from the given input stream into the specified long array. This will try to read data until the array is filled. This is the same as calling read(in, data, 0, data.length.

Parameters:
in - the input stream
data - read into this array
Throws:
IOException - if there was an I/O error while reading.
EOFException - if the entire array could not be read.

readFully

public static void readFully(InputStream in,
                             long[] data,
                             int off,
                             int len)
                      throws IOException
Reads long data from the given input stream into the specified long array. This will try to read exactly len elements.

Parameters:
in - the input stream
data - read into this array
off - offset into the array
len - read this number of elements
Throws:
IOException - if there was an I/O error while reading.
EOFException - if the specified number of elements could not be read.
IndexOutOfBoundsException - if the parameters are out of range.

PenProfile 2.x

Copyright © 2010 Livescribe Inc. All Rights Reserved.
Confidential and subject to NDA.