it.unimi.dsi.fastutil.io
Class BinIO

java.lang.Object
  extended byit.unimi.dsi.fastutil.io.BinIO

public class BinIO
extends Object

Provides static methods to perform easily binary I/O.

This class fills some gaps in the Java API. First of all, you have two buffered, easy-to-use methods to store an object to a file or load an object from a file, and two buffered, easy-to-use methods to store an object to an output stream or to load an object from an input stream.

Second, a natural operation on sequences of primitive elements is to load or store them in binary form using the DataInput conventions. This method is much more flexible than storing arrays as objects, as it allows for partial load, partial store, and makes it easy to read the resulting files from other languages.

For each primitive type, this class provides methods that read elements from a DataInput or from a filename into an array. Analogously, there are methods that store the content of an array (fragment) or the elements returned by an iterator to a DataOutput or to a given filename. Files are buffered using FastBufferedInputStream and FastBufferedOutputStream.

Finally, there are useful wrapper methods that exhibit a file as a type-specific iterator.

Since:
4.4

Method Summary
static ByteIterator asByteIterator(CharSequence filename)
          Wraps the given filename into an iterator.
static ByteIterator asByteIterator(DataInput dataInput)
          Wraps the given data input stream into an iterator.
static CharIterator asCharIterator(CharSequence filename)
          Wraps the given filename into an iterator.
static CharIterator asCharIterator(DataInput dataInput)
          Wraps the given data input stream into an iterator.
static DoubleIterator asDoubleIterator(CharSequence filename)
          Wraps the given filename into an iterator.
static DoubleIterator asDoubleIterator(DataInput dataInput)
          Wraps the given data input stream into an iterator.
static FloatIterator asFloatIterator(CharSequence filename)
          Wraps the given filename into an iterator.
static FloatIterator asFloatIterator(DataInput dataInput)
          Wraps the given data input stream into an iterator.
static IntIterator asIntIterator(CharSequence filename)
          Wraps the given filename into an iterator.
static IntIterator asIntIterator(DataInput dataInput)
          Wraps the given data input stream into an iterator.
static LongIterator asLongIterator(CharSequence filename)
          Wraps the given filename into an iterator.
static LongIterator asLongIterator(DataInput dataInput)
          Wraps the given data input stream into an iterator.
static ShortIterator asShortIterator(CharSequence filename)
          Wraps the given filename into an iterator.
static ShortIterator asShortIterator(DataInput dataInput)
          Wraps the given data input stream into an iterator.
static byte[] loadBytes(CharSequence filename)
          Loads elements from a given filename, storing them in a new array.
static int loadBytes(CharSequence filename, byte[] array)
          Loads elements from a given filename, storing them in a given array.
static int loadBytes(CharSequence filename, byte[] array, int offset, int length)
          Loads elements from a given filename, storing them in a given array fragment.
static int loadBytes(DataInput dataInput, byte[] array)
          Loads elements from a given data input, storing them in a given array.
static int loadBytes(DataInput dataInput, byte[] array, int offset, int length)
          Loads elements from a given data input, storing them in a given array fragment.
static char[] loadChars(CharSequence filename)
          Loads elements from a given filename, storing them in a new array.
static int loadChars(CharSequence filename, char[] array)
          Loads elements from a given filename, storing them in a given array.
static int loadChars(CharSequence filename, char[] array, int offset, int length)
          Loads elements from a given filename, storing them in a given array fragment.
static int loadChars(DataInput dataInput, char[] array)
          Loads elements from a given data input, storing them in a given array.
static int loadChars(DataInput dataInput, char[] array, int offset, int length)
          Loads elements from a given data input, storing them in a given array fragment.
static double[] loadDoubles(CharSequence filename)
          Loads elements from a given filename, storing them in a new array.
static int loadDoubles(CharSequence filename, double[] array)
          Loads elements from a given filename, storing them in a given array.
static int loadDoubles(CharSequence filename, double[] array, int offset, int length)
          Loads elements from a given filename, storing them in a given array fragment.
static int loadDoubles(DataInput dataInput, double[] array)
          Loads elements from a given data input, storing them in a given array.
static int loadDoubles(DataInput dataInput, double[] array, int offset, int length)
          Loads elements from a given data input, storing them in a given array fragment.
static float[] loadFloats(CharSequence filename)
          Loads elements from a given filename, storing them in a new array.
static int loadFloats(CharSequence filename, float[] array)
          Loads elements from a given filename, storing them in a given array.
static int loadFloats(CharSequence filename, float[] array, int offset, int length)
          Loads elements from a given filename, storing them in a given array fragment.
static int loadFloats(DataInput dataInput, float[] array)
          Loads elements from a given data input, storing them in a given array.
static int loadFloats(DataInput dataInput, float[] array, int offset, int length)
          Loads elements from a given data input, storing them in a given array fragment.
static int[] loadInts(CharSequence filename)
          Loads elements from a given filename, storing them in a new array.
static int loadInts(CharSequence filename, int[] array)
          Loads elements from a given filename, storing them in a given array.
static int loadInts(CharSequence filename, int[] array, int offset, int length)
          Loads elements from a given filename, storing them in a given array fragment.
static int loadInts(DataInput dataInput, int[] array)
          Loads elements from a given data input, storing them in a given array.
static int loadInts(DataInput dataInput, int[] array, int offset, int length)
          Loads elements from a given data input, storing them in a given array fragment.
static long[] loadLongs(CharSequence filename)
          Loads elements from a given filename, storing them in a new array.
static int loadLongs(CharSequence filename, long[] array)
          Loads elements from a given filename, storing them in a given array.
static int loadLongs(CharSequence filename, long[] array, int offset, int length)
          Loads elements from a given filename, storing them in a given array fragment.
static int loadLongs(DataInput dataInput, long[] array)
          Loads elements from a given data input, storing them in a given array.
static int loadLongs(DataInput dataInput, long[] array, int offset, int length)
          Loads elements from a given data input, storing them in a given array fragment.
static Object loadObject(CharSequence filename)
          Loads an object from a given file.
static Object loadObject(InputStream s)
          Loads an object from a given input stream.
static short[] loadShorts(CharSequence filename)
          Loads elements from a given filename, storing them in a new array.
static int loadShorts(CharSequence filename, short[] array)
          Loads elements from a given filename, storing them in a given array.
static int loadShorts(CharSequence filename, short[] array, int offset, int length)
          Loads elements from a given filename, storing them in a given array fragment.
static int loadShorts(DataInput dataInput, short[] array)
          Loads elements from a given data input, storing them in a given array.
static int loadShorts(DataInput dataInput, short[] array, int offset, int length)
          Loads elements from a given data input, storing them in a given array fragment.
static void storeBytes(byte[] array, CharSequence filename)
          Stores an array to a given filename.
static void storeBytes(byte[] array, DataOutput dataOutput)
          Stores an array to a given data output.
static void storeBytes(byte[] array, int offset, int length, CharSequence filename)
          Stores an array fragment to a given filename.
static void storeBytes(byte[] array, int offset, int length, DataOutput dataOutput)
          Stores an array fragment to a given data output.
static void storeBytes(ByteIterator i, CharSequence filename)
          Stores the element returned by an iterator to a given filename.
static void storeBytes(ByteIterator i, DataOutput dataOutput)
          Stores the element returned by an iterator to a given data output.
static void storeChars(char[] array, CharSequence filename)
          Stores an array to a given filename.
static void storeChars(char[] array, DataOutput dataOutput)
          Stores an array to a given data output.
static void storeChars(char[] array, int offset, int length, CharSequence filename)
          Stores an array fragment to a given filename.
static void storeChars(char[] array, int offset, int length, DataOutput dataOutput)
          Stores an array fragment to a given data output.
static void storeChars(CharIterator i, CharSequence filename)
          Stores the element returned by an iterator to a given filename.
static void storeChars(CharIterator i, DataOutput dataOutput)
          Stores the element returned by an iterator to a given data output.
static void storeDoubles(double[] array, CharSequence filename)
          Stores an array to a given filename.
static void storeDoubles(double[] array, DataOutput dataOutput)
          Stores an array to a given data output.
static void storeDoubles(double[] array, int offset, int length, CharSequence filename)
          Stores an array fragment to a given filename.
static void storeDoubles(double[] array, int offset, int length, DataOutput dataOutput)
          Stores an array fragment to a given data output.
static void storeDoubles(DoubleIterator i, CharSequence filename)
          Stores the element returned by an iterator to a given filename.
static void storeDoubles(DoubleIterator i, DataOutput dataOutput)
          Stores the element returned by an iterator to a given data output.
static void storeFloats(float[] array, CharSequence filename)
          Stores an array to a given filename.
static void storeFloats(float[] array, DataOutput dataOutput)
          Stores an array to a given data output.
static void storeFloats(float[] array, int offset, int length, CharSequence filename)
          Stores an array fragment to a given filename.
static void storeFloats(float[] array, int offset, int length, DataOutput dataOutput)
          Stores an array fragment to a given data output.
static void storeFloats(FloatIterator i, CharSequence filename)
          Stores the element returned by an iterator to a given filename.
static void storeFloats(FloatIterator i, DataOutput dataOutput)
          Stores the element returned by an iterator to a given data output.
static void storeInts(int[] array, CharSequence filename)
          Stores an array to a given filename.
static void storeInts(int[] array, DataOutput dataOutput)
          Stores an array to a given data output.
static void storeInts(int[] array, int offset, int length, CharSequence filename)
          Stores an array fragment to a given filename.
static void storeInts(int[] array, int offset, int length, DataOutput dataOutput)
          Stores an array fragment to a given data output.
static void storeInts(IntIterator i, CharSequence filename)
          Stores the element returned by an iterator to a given filename.
static void storeInts(IntIterator i, DataOutput dataOutput)
          Stores the element returned by an iterator to a given data output.
static void storeLongs(long[] array, CharSequence filename)
          Stores an array to a given filename.
static void storeLongs(long[] array, DataOutput dataOutput)
          Stores an array to a given data output.
static void storeLongs(long[] array, int offset, int length, CharSequence filename)
          Stores an array fragment to a given filename.
static void storeLongs(long[] array, int offset, int length, DataOutput dataOutput)
          Stores an array fragment to a given data output.
static void storeLongs(LongIterator i, CharSequence filename)
          Stores the element returned by an iterator to a given filename.
static void storeLongs(LongIterator i, DataOutput dataOutput)
          Stores the element returned by an iterator to a given data output.
static void storeObject(Object o, CharSequence filename)
          Stores an object in a given file.
static void storeObject(Object o, OutputStream s)
          Stores an object in a given output stream.
static void storeShorts(short[] array, CharSequence filename)
          Stores an array to a given filename.
static void storeShorts(short[] array, DataOutput dataOutput)
          Stores an array to a given data output.
static void storeShorts(short[] array, int offset, int length, CharSequence filename)
          Stores an array fragment to a given filename.
static void storeShorts(short[] array, int offset, int length, DataOutput dataOutput)
          Stores an array fragment to a given data output.
static void storeShorts(ShortIterator i, CharSequence filename)
          Stores the element returned by an iterator to a given filename.
static void storeShorts(ShortIterator i, DataOutput dataOutput)
          Stores the element returned by an iterator to a given data output.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

storeObject

public static void storeObject(Object o,
                               CharSequence filename)
                        throws IOException
Stores an object in a given file.

Parameters:
o - an object.
filename - a filename.
Throws:
IOException
See Also:
loadObject(CharSequence)

loadObject

public static Object loadObject(CharSequence filename)
                         throws IOException,
                                ClassNotFoundException
Loads an object from a given file.

Parameters:
filename - a filename.
Returns:
the object stored under the given filename.
Throws:
IOException
ClassNotFoundException
See Also:
storeObject(Object, CharSequence)

storeObject

public static void storeObject(Object o,
                               OutputStream s)
                        throws IOException
Stores an object in a given output stream. This methods buffers s, and flushes all wrappers after calling writeObject(), but does not close s.

Parameters:
o - an object.
s - an output stream.
Throws:
IOException
See Also:
loadObject(InputStream)

loadObject

public static Object loadObject(InputStream s)
                         throws IOException,
                                ClassNotFoundException
Loads an object from a given input stream.

Warning: this method buffers the input stream. As a consequence, subsequent reads from the same stream may not give the desired results, as bytes may have been read by the internal buffer, but not used by readObject(). This is a feature, as this method is targeted at one-shot reading from streams, e.g., reading exactly one object from System.in.

Parameters:
s - an input stream.
Returns:
the object read from the given input stream.
Throws:
IOException
ClassNotFoundException
See Also:
storeObject(Object, OutputStream)

loadBytes

public static int loadBytes(DataInput dataInput,
                            byte[] array,
                            int offset,
                            int length)
                     throws IOException
Loads elements from a given data input, storing them in a given array fragment.

Parameters:
dataInput - a data input.
array - an array which will be filled with data from dataInput.
offset - the index of the first element of array to be filled.
length - the number of elements of array to be filled.
Returns:
the number of elements actually read from dataInput (it might be less than length if dataInput ends).
Throws:
IOException

loadBytes

public static int loadBytes(DataInput dataInput,
                            byte[] array)
                     throws IOException
Loads elements from a given data input, storing them in a given array.

Parameters:
dataInput - a data input.
array - an array which will be filled with data from dataInput.
Returns:
the number of elements actually read from dataInput (it might be less than the array length if dataInput ends).
Throws:
IOException

loadBytes

public static int loadBytes(CharSequence filename,
                            byte[] array,
                            int offset,
                            int length)
                     throws IOException
Loads elements from a given filename, storing them in a given array fragment.

Parameters:
filename - a file name.
array - an array which will be filled with data from the specified file.
offset - the index of the first element of array to be filled.
length - the number of elements of array to be filled.
Returns:
the number of elements actually read from the given file (it might be less than length if the file is too short).
Throws:
IOException

loadBytes

public static int loadBytes(CharSequence filename,
                            byte[] array)
                     throws IOException
Loads elements from a given filename, storing them in a given array.

Parameters:
filename - a file name.
array - an array which will be filled with data from the specified file.
Returns:
the number of elements actually read from the given file (it might be less than the array length if the file is too short).
Throws:
IOException

loadBytes

public static byte[] loadBytes(CharSequence filename)
                        throws IOException
Loads elements from a given filename, storing them in a new array.

Note that the length of the returned array will be computed dividing the specified file size by the number of bytes used to represent each element.

Parameters:
filename - a file name.
Returns:
an array filled with the content of the specified file.
Throws:
IOException

storeBytes

public static void storeBytes(byte[] array,
                              int offset,
                              int length,
                              DataOutput dataOutput)
                       throws IOException
Stores an array fragment to a given data output.

Parameters:
array - an array whose elements will be written to dataOutput.
offset - the index of the first element of array to be written.
length - the number of elements of array to be written.
dataOutput - a data output.
Throws:
IOException

storeBytes

public static void storeBytes(byte[] array,
                              DataOutput dataOutput)
                       throws IOException
Stores an array to a given data output.

Parameters:
array - an array whose elements will be written to dataOutput.
dataOutput - a data output.
Throws:
IOException

storeBytes

public static void storeBytes(byte[] array,
                              int offset,
                              int length,
                              CharSequence filename)
                       throws IOException
Stores an array fragment to a given filename.

Parameters:
array - an array whose elements will be written to filename.
offset - the index of the first element of array to be written.
length - the number of elements of array to be written.
filename - a file name.
Throws:
IOException

storeBytes

public static void storeBytes(byte[] array,
                              CharSequence filename)
                       throws IOException
Stores an array to a given filename.

Parameters:
array - an array whose elements will be written to filename.
filename - a file name.
Throws:
IOException

storeBytes

public static void storeBytes(ByteIterator i,
                              DataOutput dataOutput)
                       throws IOException
Stores the element returned by an iterator to a given data output.

Parameters:
i - an iterator whose output will be written to dataOutput.
dataOutput - a file name.
Throws:
IOException

storeBytes

public static void storeBytes(ByteIterator i,
                              CharSequence filename)
                       throws IOException
Stores the element returned by an iterator to a given filename.

Parameters:
i - an iterator whose output will be written to filename.
filename - a file name.
Throws:
IOException

asByteIterator

public static ByteIterator asByteIterator(DataInput dataInput)
                                   throws IOException
Wraps the given data input stream into an iterator.

Parameters:
dataInput - a data input.
Throws:
IOException

asByteIterator

public static ByteIterator asByteIterator(CharSequence filename)
                                   throws IOException
Wraps the given filename into an iterator.

Parameters:
filename - a file name.
Throws:
IOException

loadShorts

public static int loadShorts(DataInput dataInput,
                             short[] array,
                             int offset,
                             int length)
                      throws IOException
Loads elements from a given data input, storing them in a given array fragment.

Parameters:
dataInput - a data input.
array - an array which will be filled with data from dataInput.
offset - the index of the first element of array to be filled.
length - the number of elements of array to be filled.
Returns:
the number of elements actually read from dataInput (it might be less than length if dataInput ends).
Throws:
IOException

loadShorts

public static int loadShorts(DataInput dataInput,
                             short[] array)
                      throws IOException
Loads elements from a given data input, storing them in a given array.

Parameters:
dataInput - a data input.
array - an array which will be filled with data from dataInput.
Returns:
the number of elements actually read from dataInput (it might be less than the array length if dataInput ends).
Throws:
IOException

loadShorts

public static int loadShorts(CharSequence filename,
                             short[] array,
                             int offset,
                             int length)
                      throws IOException
Loads elements from a given filename, storing them in a given array fragment.

Parameters:
filename - a file name.
array - an array which will be filled with data from the specified file.
offset - the index of the first element of array to be filled.
length - the number of elements of array to be filled.
Returns:
the number of elements actually read from the given file (it might be less than length if the file is too short).
Throws:
IOException

loadShorts

public static int loadShorts(CharSequence filename,
                             short[] array)
                      throws IOException
Loads elements from a given filename, storing them in a given array.

Parameters:
filename - a file name.
array - an array which will be filled with data from the specified file.
Returns:
the number of elements actually read from the given file (it might be less than the array length if the file is too short).
Throws:
IOException

loadShorts

public static short[] loadShorts(CharSequence filename)
                          throws IOException
Loads elements from a given filename, storing them in a new array.

Note that the length of the returned array will be computed dividing the specified file size by the number of bytes used to represent each element.

Parameters:
filename - a file name.
Returns:
an array filled with the content of the specified file.
Throws:
IOException

storeShorts

public static void storeShorts(short[] array,
                               int offset,
                               int length,
                               DataOutput dataOutput)
                        throws IOException
Stores an array fragment to a given data output.

Parameters:
array - an array whose elements will be written to dataOutput.
offset - the index of the first element of array to be written.
length - the number of elements of array to be written.
dataOutput - a data output.
Throws:
IOException

storeShorts

public static void storeShorts(short[] array,
                               DataOutput dataOutput)
                        throws IOException
Stores an array to a given data output.

Parameters:
array - an array whose elements will be written to dataOutput.
dataOutput - a data output.
Throws:
IOException

storeShorts

public static void storeShorts(short[] array,
                               int offset,
                               int length,
                               CharSequence filename)
                        throws IOException
Stores an array fragment to a given filename.

Parameters:
array - an array whose elements will be written to filename.
offset - the index of the first element of array to be written.
length - the number of elements of array to be written.
filename - a file name.
Throws:
IOException

storeShorts

public static void storeShorts(short[] array,
                               CharSequence filename)
                        throws IOException
Stores an array to a given filename.

Parameters:
array - an array whose elements will be written to filename.
filename - a file name.
Throws:
IOException

storeShorts

public static void storeShorts(ShortIterator i,
                               DataOutput dataOutput)
                        throws IOException
Stores the element returned by an iterator to a given data output.

Parameters:
i - an iterator whose output will be written to dataOutput.
dataOutput - a file name.
Throws:
IOException

storeShorts

public static void storeShorts(ShortIterator i,
                               CharSequence filename)
                        throws IOException
Stores the element returned by an iterator to a given filename.

Parameters:
i - an iterator whose output will be written to filename.
filename - a file name.
Throws:
IOException

asShortIterator

public static ShortIterator asShortIterator(DataInput dataInput)
                                     throws IOException
Wraps the given data input stream into an iterator.

Parameters:
dataInput - a data input.
Throws:
IOException

asShortIterator

public static ShortIterator asShortIterator(CharSequence filename)
                                     throws IOException
Wraps the given filename into an iterator.

Parameters:
filename - a file name.
Throws:
IOException

loadChars

public static int loadChars(DataInput dataInput,
                            char[] array,
                            int offset,
                            int length)
                     throws IOException
Loads elements from a given data input, storing them in a given array fragment.

Parameters:
dataInput - a data input.
array - an array which will be filled with data from dataInput.
offset - the index of the first element of array to be filled.
length - the number of elements of array to be filled.
Returns:
the number of elements actually read from dataInput (it might be less than length if dataInput ends).
Throws:
IOException

loadChars

public static int loadChars(DataInput dataInput,
                            char[] array)
                     throws IOException
Loads elements from a given data input, storing them in a given array.

Parameters:
dataInput - a data input.
array - an array which will be filled with data from dataInput.
Returns:
the number of elements actually read from dataInput (it might be less than the array length if dataInput ends).
Throws:
IOException

loadChars

public static int loadChars(CharSequence filename,
                            char[] array,
                            int offset,
                            int length)
                     throws IOException
Loads elements from a given filename, storing them in a given array fragment.

Parameters:
filename - a file name.
array - an array which will be filled with data from the specified file.
offset - the index of the first element of array to be filled.
length - the number of elements of array to be filled.
Returns:
the number of elements actually read from the given file (it might be less than length if the file is too short).
Throws:
IOException

loadChars

public static int loadChars(CharSequence filename,
                            char[] array)
                     throws IOException
Loads elements from a given filename, storing them in a given array.

Parameters:
filename - a file name.
array - an array which will be filled with data from the specified file.
Returns:
the number of elements actually read from the given file (it might be less than the array length if the file is too short).
Throws:
IOException

loadChars

public static char[] loadChars(CharSequence filename)
                        throws IOException
Loads elements from a given filename, storing them in a new array.

Note that the length of the returned array will be computed dividing the specified file size by the number of bytes used to represent each element.

Parameters:
filename - a file name.
Returns:
an array filled with the content of the specified file.
Throws:
IOException

storeChars

public static void storeChars(char[] array,
                              int offset,
                              int length,
                              DataOutput dataOutput)
                       throws IOException
Stores an array fragment to a given data output.

Parameters:
array - an array whose elements will be written to dataOutput.
offset - the index of the first element of array to be written.
length - the number of elements of array to be written.
dataOutput - a data output.
Throws:
IOException

storeChars

public static void storeChars(char[] array,
                              DataOutput dataOutput)
                       throws IOException
Stores an array to a given data output.

Parameters:
array - an array whose elements will be written to dataOutput.
dataOutput - a data output.
Throws:
IOException

storeChars

public static void storeChars(char[] array,
                              int offset,
                              int length,
                              CharSequence filename)
                       throws IOException
Stores an array fragment to a given filename.

Parameters:
array - an array whose elements will be written to filename.
offset - the index of the first element of array to be written.
length - the number of elements of array to be written.
filename - a file name.
Throws:
IOException

storeChars

public static void storeChars(char[] array,
                              CharSequence filename)
                       throws IOException
Stores an array to a given filename.

Parameters:
array - an array whose elements will be written to filename.
filename - a file name.
Throws:
IOException

storeChars

public static void storeChars(CharIterator i,
                              DataOutput dataOutput)
                       throws IOException
Stores the element returned by an iterator to a given data output.

Parameters:
i - an iterator whose output will be written to dataOutput.
dataOutput - a file name.
Throws:
IOException

storeChars

public static void storeChars(CharIterator i,
                              CharSequence filename)
                       throws IOException
Stores the element returned by an iterator to a given filename.

Parameters:
i - an iterator whose output will be written to filename.
filename - a file name.
Throws:
IOException

asCharIterator

public static CharIterator asCharIterator(DataInput dataInput)
                                   throws IOException
Wraps the given data input stream into an iterator.

Parameters:
dataInput - a data input.
Throws:
IOException

asCharIterator

public static CharIterator asCharIterator(CharSequence filename)
                                   throws IOException
Wraps the given filename into an iterator.

Parameters:
filename - a file name.
Throws:
IOException

loadInts

public static int loadInts(DataInput dataInput,
                           int[] array,
                           int offset,
                           int length)
                    throws IOException
Loads elements from a given data input, storing them in a given array fragment.

Parameters:
dataInput - a data input.
array - an array which will be filled with data from dataInput.
offset - the index of the first element of array to be filled.
length - the number of elements of array to be filled.
Returns:
the number of elements actually read from dataInput (it might be less than length if dataInput ends).
Throws:
IOException

loadInts

public static int loadInts(DataInput dataInput,
                           int[] array)
                    throws IOException
Loads elements from a given data input, storing them in a given array.

Parameters:
dataInput - a data input.
array - an array which will be filled with data from dataInput.
Returns:
the number of elements actually read from dataInput (it might be less than the array length if dataInput ends).
Throws:
IOException

loadInts

public static int loadInts(CharSequence filename,
                           int[] array,
                           int offset,
                           int length)
                    throws IOException
Loads elements from a given filename, storing them in a given array fragment.

Parameters:
filename - a file name.
array - an array which will be filled with data from the specified file.
offset - the index of the first element of array to be filled.
length - the number of elements of array to be filled.
Returns:
the number of elements actually read from the given file (it might be less than length if the file is too short).
Throws:
IOException

loadInts

public static int loadInts(CharSequence filename,
                           int[] array)
                    throws IOException
Loads elements from a given filename, storing them in a given array.

Parameters:
filename - a file name.
array - an array which will be filled with data from the specified file.
Returns:
the number of elements actually read from the given file (it might be less than the array length if the file is too short).
Throws:
IOException

loadInts

public static int[] loadInts(CharSequence filename)
                      throws IOException
Loads elements from a given filename, storing them in a new array.

Note that the length of the returned array will be computed dividing the specified file size by the number of bytes used to represent each element.

Parameters:
filename - a file name.
Returns:
an array filled with the content of the specified file.
Throws:
IOException

storeInts

public static void storeInts(int[] array,
                             int offset,
                             int length,
                             DataOutput dataOutput)
                      throws IOException
Stores an array fragment to a given data output.

Parameters:
array - an array whose elements will be written to dataOutput.
offset - the index of the first element of array to be written.
length - the number of elements of array to be written.
dataOutput - a data output.
Throws:
IOException

storeInts

public static void storeInts(int[] array,
                             DataOutput dataOutput)
                      throws IOException
Stores an array to a given data output.

Parameters:
array - an array whose elements will be written to dataOutput.
dataOutput - a data output.
Throws:
IOException

storeInts

public static void storeInts(int[] array,
                             int offset,
                             int length,
                             CharSequence filename)
                      throws IOException
Stores an array fragment to a given filename.

Parameters:
array - an array whose elements will be written to filename.
offset - the index of the first element of array to be written.
length - the number of elements of array to be written.
filename - a file name.
Throws:
IOException

storeInts

public static void storeInts(int[] array,
                             CharSequence filename)
                      throws IOException
Stores an array to a given filename.

Parameters:
array - an array whose elements will be written to filename.
filename - a file name.
Throws:
IOException

storeInts

public static void storeInts(IntIterator i,
                             DataOutput dataOutput)
                      throws IOException
Stores the element returned by an iterator to a given data output.

Parameters:
i - an iterator whose output will be written to dataOutput.
dataOutput - a file name.
Throws:
IOException

storeInts

public static void storeInts(IntIterator i,
                             CharSequence filename)
                      throws IOException
Stores the element returned by an iterator to a given filename.

Parameters:
i - an iterator whose output will be written to filename.
filename - a file name.
Throws:
IOException

asIntIterator

public static IntIterator asIntIterator(DataInput dataInput)
                                 throws IOException
Wraps the given data input stream into an iterator.

Parameters:
dataInput - a data input.
Throws:
IOException

asIntIterator

public static IntIterator asIntIterator(CharSequence filename)
                                 throws IOException
Wraps the given filename into an iterator.

Parameters:
filename - a file name.
Throws:
IOException

loadLongs

public static int loadLongs(DataInput dataInput,
                            long[] array,
                            int offset,
                            int length)
                     throws IOException
Loads elements from a given data input, storing them in a given array fragment.

Parameters:
dataInput - a data input.
array - an array which will be filled with data from dataInput.
offset - the index of the first element of array to be filled.
length - the number of elements of array to be filled.
Returns:
the number of elements actually read from dataInput (it might be less than length if dataInput ends).
Throws:
IOException

loadLongs

public static int loadLongs(DataInput dataInput,
                            long[] array)
                     throws IOException
Loads elements from a given data input, storing them in a given array.

Parameters:
dataInput - a data input.
array - an array which will be filled with data from dataInput.
Returns:
the number of elements actually read from dataInput (it might be less than the array length if dataInput ends).
Throws:
IOException

loadLongs

public static int loadLongs(CharSequence filename,
                            long[] array,
                            int offset,
                            int length)
                     throws IOException
Loads elements from a given filename, storing them in a given array fragment.

Parameters:
filename - a file name.
array - an array which will be filled with data from the specified file.
offset - the index of the first element of array to be filled.
length - the number of elements of array to be filled.
Returns:
the number of elements actually read from the given file (it might be less than length if the file is too short).
Throws:
IOException

loadLongs

public static int loadLongs(CharSequence filename,
                            long[] array)
                     throws IOException
Loads elements from a given filename, storing them in a given array.

Parameters:
filename - a file name.
array - an array which will be filled with data from the specified file.
Returns:
the number of elements actually read from the given file (it might be less than the array length if the file is too short).
Throws:
IOException

loadLongs

public static long[] loadLongs(CharSequence filename)
                        throws IOException
Loads elements from a given filename, storing them in a new array.

Note that the length of the returned array will be computed dividing the specified file size by the number of bytes used to represent each element.

Parameters:
filename - a file name.
Returns:
an array filled with the content of the specified file.
Throws:
IOException

storeLongs

public static void storeLongs(long[] array,
                              int offset,
                              int length,
                              DataOutput dataOutput)
                       throws IOException
Stores an array fragment to a given data output.

Parameters:
array - an array whose elements will be written to dataOutput.
offset - the index of the first element of array to be written.
length - the number of elements of array to be written.
dataOutput - a data output.
Throws:
IOException

storeLongs

public static void storeLongs(long[] array,
                              DataOutput dataOutput)
                       throws IOException
Stores an array to a given data output.

Parameters:
array - an array whose elements will be written to dataOutput.
dataOutput - a data output.
Throws:
IOException

storeLongs

public static void storeLongs(long[] array,
                              int offset,
                              int length,
                              CharSequence filename)
                       throws IOException
Stores an array fragment to a given filename.

Parameters:
array - an array whose elements will be written to filename.
offset - the index of the first element of array to be written.
length - the number of elements of array to be written.
filename - a file name.
Throws:
IOException

storeLongs

public static void storeLongs(long[] array,
                              CharSequence filename)
                       throws IOException
Stores an array to a given filename.

Parameters:
array - an array whose elements will be written to filename.
filename - a file name.
Throws:
IOException

storeLongs

public static void storeLongs(LongIterator i,
                              DataOutput dataOutput)
                       throws IOException
Stores the element returned by an iterator to a given data output.

Parameters:
i - an iterator whose output will be written to dataOutput.
dataOutput - a file name.
Throws:
IOException

storeLongs

public static void storeLongs(LongIterator i,
                              CharSequence filename)
                       throws IOException
Stores the element returned by an iterator to a given filename.

Parameters:
i - an iterator whose output will be written to filename.
filename - a file name.
Throws:
IOException

asLongIterator

public static LongIterator asLongIterator(DataInput dataInput)
                                   throws IOException
Wraps the given data input stream into an iterator.

Parameters:
dataInput - a data input.
Throws:
IOException

asLongIterator

public static LongIterator asLongIterator(CharSequence filename)
                                   throws IOException
Wraps the given filename into an iterator.

Parameters:
filename - a file name.
Throws:
IOException

loadFloats

public static int loadFloats(DataInput dataInput,
                             float[] array,
                             int offset,
                             int length)
                      throws IOException
Loads elements from a given data input, storing them in a given array fragment.

Parameters:
dataInput - a data input.
array - an array which will be filled with data from dataInput.
offset - the index of the first element of array to be filled.
length - the number of elements of array to be filled.
Returns:
the number of elements actually read from dataInput (it might be less than length if dataInput ends).
Throws:
IOException

loadFloats

public static int loadFloats(DataInput dataInput,
                             float[] array)
                      throws IOException
Loads elements from a given data input, storing them in a given array.

Parameters:
dataInput - a data input.
array - an array which will be filled with data from dataInput.
Returns:
the number of elements actually read from dataInput (it might be less than the array length if dataInput ends).
Throws:
IOException

loadFloats

public static int loadFloats(CharSequence filename,
                             float[] array,
                             int offset,
                             int length)
                      throws IOException
Loads elements from a given filename, storing them in a given array fragment.

Parameters:
filename - a file name.
array - an array which will be filled with data from the specified file.
offset - the index of the first element of array to be filled.
length - the number of elements of array to be filled.
Returns:
the number of elements actually read from the given file (it might be less than length if the file is too short).
Throws:
IOException

loadFloats

public static int loadFloats(CharSequence filename,
                             float[] array)
                      throws IOException
Loads elements from a given filename, storing them in a given array.

Parameters:
filename - a file name.
array - an array which will be filled with data from the specified file.
Returns:
the number of elements actually read from the given file (it might be less than the array length if the file is too short).
Throws:
IOException

loadFloats

public static float[] loadFloats(CharSequence filename)
                          throws IOException
Loads elements from a given filename, storing them in a new array.

Note that the length of the returned array will be computed dividing the specified file size by the number of bytes used to represent each element.

Parameters:
filename - a file name.
Returns:
an array filled with the content of the specified file.
Throws:
IOException

storeFloats

public static void storeFloats(float[] array,
                               int offset,
                               int length,
                               DataOutput dataOutput)
                        throws IOException
Stores an array fragment to a given data output.

Parameters:
array - an array whose elements will be written to dataOutput.
offset - the index of the first element of array to be written.
length - the number of elements of array to be written.
dataOutput - a data output.
Throws:
IOException

storeFloats

public static void storeFloats(float[] array,
                               DataOutput dataOutput)
                        throws IOException
Stores an array to a given data output.

Parameters:
array - an array whose elements will be written to dataOutput.
dataOutput - a data output.
Throws:
IOException

storeFloats

public static void storeFloats(float[] array,
                               int offset,
                               int length,
                               CharSequence filename)
                        throws IOException
Stores an array fragment to a given filename.

Parameters:
array - an array whose elements will be written to filename.
offset - the index of the first element of array to be written.
length - the number of elements of array to be written.
filename - a file name.
Throws:
IOException

storeFloats

public static void storeFloats(float[] array,
                               CharSequence filename)
                        throws IOException
Stores an array to a given filename.

Parameters:
array - an array whose elements will be written to filename.
filename - a file name.
Throws:
IOException

storeFloats

public static void storeFloats(FloatIterator i,
                               DataOutput dataOutput)
                        throws IOException
Stores the element returned by an iterator to a given data output.

Parameters:
i - an iterator whose output will be written to dataOutput.
dataOutput - a file name.
Throws:
IOException

storeFloats

public static void storeFloats(FloatIterator i,
                               CharSequence filename)
                        throws IOException
Stores the element returned by an iterator to a given filename.

Parameters:
i - an iterator whose output will be written to filename.
filename - a file name.
Throws:
IOException

asFloatIterator

public static FloatIterator asFloatIterator(DataInput dataInput)
                                     throws IOException
Wraps the given data input stream into an iterator.

Parameters:
dataInput - a data input.
Throws:
IOException

asFloatIterator

public static FloatIterator asFloatIterator(CharSequence filename)
                                     throws IOException
Wraps the given filename into an iterator.

Parameters:
filename - a file name.
Throws:
IOException

loadDoubles

public static int loadDoubles(DataInput dataInput,
                              double[] array,
                              int offset,
                              int length)
                       throws IOException
Loads elements from a given data input, storing them in a given array fragment.

Parameters:
dataInput - a data input.
array - an array which will be filled with data from dataInput.
offset - the index of the first element of array to be filled.
length - the number of elements of array to be filled.
Returns:
the number of elements actually read from dataInput (it might be less than length if dataInput ends).
Throws:
IOException

loadDoubles

public static int loadDoubles(DataInput dataInput,
                              double[] array)
                       throws IOException
Loads elements from a given data input, storing them in a given array.

Parameters:
dataInput - a data input.
array - an array which will be filled with data from dataInput.
Returns:
the number of elements actually read from dataInput (it might be less than the array length if dataInput ends).
Throws:
IOException

loadDoubles

public static int loadDoubles(CharSequence filename,
                              double[] array,
                              int offset,
                              int length)
                       throws IOException
Loads elements from a given filename, storing them in a given array fragment.

Parameters:
filename - a file name.
array - an array which will be filled with data from the specified file.
offset - the index of the first element of array to be filled.
length - the number of elements of array to be filled.
Returns:
the number of elements actually read from the given file (it might be less than length if the file is too short).
Throws:
IOException

loadDoubles

public static int loadDoubles(CharSequence filename,
                              double[] array)
                       throws IOException
Loads elements from a given filename, storing them in a given array.

Parameters:
filename - a file name.
array - an array which will be filled with data from the specified file.
Returns:
the number of elements actually read from the given file (it might be less than the array length if the file is too short).
Throws:
IOException

loadDoubles

public static double[] loadDoubles(CharSequence filename)
                            throws IOException
Loads elements from a given filename, storing them in a new array.

Note that the length of the returned array will be computed dividing the specified file size by the number of bytes used to represent each element.

Parameters:
filename - a file name.
Returns:
an array filled with the content of the specified file.
Throws:
IOException

storeDoubles

public static void storeDoubles(double[] array,
                                int offset,
                                int length,
                                DataOutput dataOutput)
                         throws IOException
Stores an array fragment to a given data output.

Parameters:
array - an array whose elements will be written to dataOutput.
offset - the index of the first element of array to be written.
length - the number of elements of array to be written.
dataOutput - a data output.
Throws:
IOException

storeDoubles

public static void storeDoubles(double[] array,
                                DataOutput dataOutput)
                         throws IOException
Stores an array to a given data output.

Parameters:
array - an array whose elements will be written to dataOutput.
dataOutput - a data output.
Throws:
IOException

storeDoubles

public static void storeDoubles(double[] array,
                                int offset,
                                int length,
                                CharSequence filename)
                         throws IOException
Stores an array fragment to a given filename.

Parameters:
array - an array whose elements will be written to filename.
offset - the index of the first element of array to be written.
length - the number of elements of array to be written.
filename - a file name.
Throws:
IOException

storeDoubles

public static void storeDoubles(double[] array,
                                CharSequence filename)
                         throws IOException
Stores an array to a given filename.

Parameters:
array - an array whose elements will be written to filename.
filename - a file name.
Throws:
IOException

storeDoubles

public static void storeDoubles(DoubleIterator i,
                                DataOutput dataOutput)
                         throws IOException
Stores the element returned by an iterator to a given data output.

Parameters:
i - an iterator whose output will be written to dataOutput.
dataOutput - a file name.
Throws:
IOException

storeDoubles

public static void storeDoubles(DoubleIterator i,
                                CharSequence filename)
                         throws IOException
Stores the element returned by an iterator to a given filename.

Parameters:
i - an iterator whose output will be written to filename.
filename - a file name.
Throws:
IOException

asDoubleIterator

public static DoubleIterator asDoubleIterator(DataInput dataInput)
                                       throws IOException
Wraps the given data input stream into an iterator.

Parameters:
dataInput - a data input.
Throws:
IOException

asDoubleIterator

public static DoubleIterator asDoubleIterator(CharSequence filename)
                                       throws IOException
Wraps the given filename into an iterator.

Parameters:
filename - a file name.
Throws:
IOException