com.imagero.uio.io
Class IOutils

java.lang.Object
  extended bycom.imagero.uio.io.IOutils

public class IOutils
extends java.lang.Object

IOutils.java


Constructor Summary
IOutils()
           
 
Method Summary
static void closeStream(java.io.BufferedReader br)
          close silently stream
no exception it thrown
static void closeStream(java.io.BufferedWriter bw)
          close silently stream
no exception it thrown
static void closeStream(java.io.InputStream is)
          close silently stream
no exception it thrown
static void closeStream(java.io.OutputStream os)
          close silently stream
no exception it thrown
static void closeStream(java.io.RandomAccessFile raf)
          close silently stream
no exception it thrown
static void closeStream(RandomAccessInput ro)
          close silently stream
no exception it thrown
static void closeStream(RandomAccessIO ro)
           
static void closeStream(RandomAccessOutput ro)
           
static void convertFrom2C(byte[] b0)
          Convert byte array from 2's complement
static void convertFrom2C(int[] b0)
          Convert int array from 2's complement
static void convertFrom2C(long[] b0)
          Convert long array from 2's complement
static void convertFrom2C(short[] b0)
          Convert short array from 2's complement
static long copy(java.io.File src, java.io.File dest)
          Copy file.
static long copy(java.io.InputStream in, java.io.DataOutput out)
          copy data from source to destination stream
static long copy(java.io.InputStream in, java.io.OutputStream out)
          copy data from in to out
static long copy(long length, java.io.InputStream in, java.io.DataOutput out)
          copy length bytes from source to destination stream
static long copy(long length, java.io.InputStream in, java.io.OutputStream out)
          copy length bytes from in to out
static long copy(long offset, long length, RandomAccessInput in, java.io.DataOutput out)
          copy data from source to destination stream
static long copy(long offset, long length, RandomAccessInput in, java.io.OutputStream out)
          copy data from source to destination stream
static long copy(RandomAccessInput in, long offset, java.io.DataOutput out)
          copy data from source to destination stream
static long copy(RandomAccessInput in, long offset, java.io.OutputStream out)
          copy data from in to out
static java.lang.String getExtension(java.io.File f)
           
static void printHexByte(int value)
           
static void printHexInt(int value)
           
static void printHexLong(long value)
           
static void printHexShort(int value)
           
static void printlnHexByte(int value)
           
static void printlnHexInt(int value)
           
static void printlnHexLong(long value)
           
static void printlnHexShort(int value)
           
static void readFully(java.io.InputStream in, byte[] b)
           
static void readFully(java.io.InputStream in, byte[] b, int off, int len)
           
static int readFully2(java.io.InputStream in, byte[] b)
          this method is like readFully, but instead of throwing EOFException it returns count of read bytes
static int readFully2(java.io.InputStream in, byte[] b, int off, int len)
          this method is like readFully, but instead of throwing EOFException it returns count of read bytes
static void readFullyS(java.io.DataInput ro, byte[] b0)
          Read byte array and convert from 2's complement
static void readFullyS(RandomAccessInput ro, int[] b0)
          Read int array and convert from 2's complement
static void readFullyS(RandomAccessInput ro, long[] b0)
          Read short array and convert from 2's complement
static void readFullyS(RandomAccessInput ro, short[] b0)
          Read short array and convert from 2's complement.
static int readInt(java.io.DataInput in, int byteOrder)
          read big/little-endian int
static int readInt(java.io.InputStream in, int byteOrder)
          read big/little-endian int
static int readInt49(java.io.DataInput in)
          read big-endian int
static int readInt49(java.io.InputStream in)
          read big-endian int
static int readInt4D(java.io.DataInput in)
          read big-endian int
static int readInt4D(java.io.InputStream in)
          read little-endian int
static long readLong49(java.io.DataInput in)
          read big-endian long
static long readLong49(java.io.InputStream in)
          read big-endian long
static long readLong4D(java.io.DataInput in)
          read little-endian long
static long readLong4D(java.io.InputStream in)
          read little-endian long
static byte readSByte(java.io.DataInput ro)
           
static int readShort(java.io.DataInput in, int byteOrder)
           
static int readShort(java.io.InputStream in, int byteOrder)
          read big/little-endian short
static int readShort49(java.io.DataInput in)
          read big-endian short
static int readShort49(java.io.InputStream in)
          read big-endian short
static int readShort4D(java.io.DataInput in)
          read little-endian short
static int readShort4D(java.io.InputStream in)
          read little-endian short
static int readSInt(java.io.DataInput ro)
           
static long readSLong(java.io.DataInput ro)
           
static short readSShort(java.io.DataInput ro)
           
static java.lang.String toBinaryString(byte value)
           
static java.lang.String toBinaryString(char value)
           
static java.lang.String toBinaryString(int value, int length)
           
static java.lang.String toHexString(byte value)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IOutils

public IOutils()
Method Detail

closeStream

public static void closeStream(java.io.BufferedWriter bw)
close silently stream
no exception it thrown

Parameters:
bw -

closeStream

public static void closeStream(java.io.BufferedReader br)
close silently stream
no exception it thrown

Parameters:
br -

closeStream

public static void closeStream(java.io.InputStream is)
close silently stream
no exception it thrown

Parameters:
is -

closeStream

public static void closeStream(java.io.OutputStream os)
close silently stream
no exception it thrown

Parameters:
os -

closeStream

public static void closeStream(java.io.RandomAccessFile raf)
close silently stream
no exception it thrown

Parameters:
raf -

closeStream

public static void closeStream(RandomAccessInput ro)
close silently stream
no exception it thrown

Parameters:
ro -

closeStream

public static void closeStream(RandomAccessOutput ro)

closeStream

public static void closeStream(RandomAccessIO ro)

toBinaryString

public static java.lang.String toBinaryString(byte value)

toBinaryString

public static java.lang.String toBinaryString(char value)

toBinaryString

public static java.lang.String toBinaryString(int value,
                                              int length)

toHexString

public static java.lang.String toHexString(byte value)

printHexByte

public static void printHexByte(int value)

printlnHexByte

public static void printlnHexByte(int value)

printHexShort

public static void printHexShort(int value)

printlnHexShort

public static void printlnHexShort(int value)

printHexInt

public static void printHexInt(int value)

printlnHexInt

public static void printlnHexInt(int value)

printHexLong

public static void printHexLong(long value)

printlnHexLong

public static void printlnHexLong(long value)

getExtension

public static java.lang.String getExtension(java.io.File f)

readShort4D

public static int readShort4D(java.io.InputStream in)
                       throws java.io.IOException
read little-endian short

Throws:
java.io.IOException

readShort4D

public static int readShort4D(java.io.DataInput in)
                       throws java.io.IOException
read little-endian short

Throws:
java.io.IOException

readShort49

public static int readShort49(java.io.InputStream in)
                       throws java.io.IOException
read big-endian short

Throws:
java.io.IOException

readShort49

public static int readShort49(java.io.DataInput in)
                       throws java.io.IOException
read big-endian short

Throws:
java.io.IOException

readInt4D

public static int readInt4D(java.io.InputStream in)
                     throws java.io.IOException
read little-endian int

Throws:
java.io.IOException

readInt4D

public static int readInt4D(java.io.DataInput in)
                     throws java.io.IOException
read big-endian int

Throws:
java.io.IOException

readInt49

public static int readInt49(java.io.InputStream in)
                     throws java.io.IOException
read big-endian int

Throws:
java.io.IOException

readInt49

public static int readInt49(java.io.DataInput in)
                     throws java.io.IOException
read big-endian int

Throws:
java.io.IOException

readLong4D

public static long readLong4D(java.io.InputStream in)
                       throws java.io.IOException
read little-endian long

Throws:
java.io.IOException

readLong4D

public static long readLong4D(java.io.DataInput in)
                       throws java.io.IOException
read little-endian long

Throws:
java.io.IOException

readLong49

public static long readLong49(java.io.InputStream in)
                       throws java.io.IOException
read big-endian long

Throws:
java.io.IOException

readLong49

public static long readLong49(java.io.DataInput in)
                       throws java.io.IOException
read big-endian long

Throws:
java.io.IOException

readSByte

public static byte readSByte(java.io.DataInput ro)
                      throws java.io.IOException
Throws:
java.io.IOException

readSShort

public static short readSShort(java.io.DataInput ro)
                        throws java.io.IOException
Throws:
java.io.IOException

readSInt

public static int readSInt(java.io.DataInput ro)
                    throws java.io.IOException
Throws:
java.io.IOException

readSLong

public static long readSLong(java.io.DataInput ro)
                      throws java.io.IOException
Throws:
java.io.IOException

readFullyS

public static void readFullyS(java.io.DataInput ro,
                              byte[] b0)
                       throws java.io.IOException
Read byte array and convert from 2's complement

Parameters:
ro - RandomAccessRO
b0 - byte array
Throws:
java.io.IOException

convertFrom2C

public static final void convertFrom2C(byte[] b0)
Convert byte array from 2's complement


readFullyS

public static void readFullyS(RandomAccessInput ro,
                              short[] b0)
                       throws java.io.IOException
Read short array and convert from 2's complement.

Parameters:
ro - RandomAccessRO
b0 - short array
Throws:
java.io.IOException

convertFrom2C

public static final void convertFrom2C(short[] b0)
Convert short array from 2's complement


readFullyS

public static void readFullyS(RandomAccessInput ro,
                              int[] b0)
                       throws java.io.IOException
Read int array and convert from 2's complement

Parameters:
ro - RandomAccessRO
b0 - int array
Throws:
java.io.IOException

convertFrom2C

public static final void convertFrom2C(int[] b0)
Convert int array from 2's complement


readFullyS

public static void readFullyS(RandomAccessInput ro,
                              long[] b0)
                       throws java.io.IOException
Read short array and convert from 2's complement

Parameters:
ro - RandomAccessRO
b0 - long array
Throws:
java.io.IOException

convertFrom2C

public static final void convertFrom2C(long[] b0)
Convert long array from 2's complement


readFully

public static void readFully(java.io.InputStream in,
                             byte[] b)
                      throws UnexpectedEOFException,
                             java.io.IOException
Throws:
UnexpectedEOFException
java.io.IOException

readFully

public static void readFully(java.io.InputStream in,
                             byte[] b,
                             int off,
                             int len)
                      throws UnexpectedEOFException,
                             java.io.IOException
Throws:
UnexpectedEOFException
java.io.IOException

readFully2

public static int readFully2(java.io.InputStream in,
                             byte[] b)
                      throws java.io.IOException
this method is like readFully, but instead of throwing EOFException it returns count of read bytes

Parameters:
in - InputStream to read
b - byte array to fill
Returns:
number of bytes read into the buffer, or -1 if EOF was reached
Throws:
java.io.IOException

readFully2

public static int readFully2(java.io.InputStream in,
                             byte[] b,
                             int off,
                             int len)
                      throws java.io.IOException
this method is like readFully, but instead of throwing EOFException it returns count of read bytes

Parameters:
in - InputStream to read
b - byte array to fill
off - start offset in byte array
len - number of bytes to read
Returns:
number of bytes read into the buffer, or -1 if EOF was reached
Throws:
java.io.IOException

copy

public static long copy(long length,
                        java.io.InputStream in,
                        java.io.OutputStream out)
                 throws java.io.IOException
copy length bytes from in to out

Parameters:
length - amount of bytes to copy
in - source InputStream
out - destination OutputStream
Throws:
java.io.IOException

copy

public static long copy(long length,
                        java.io.InputStream in,
                        java.io.DataOutput out)
                 throws java.io.IOException
copy length bytes from source to destination stream

Parameters:
length - amount of bytes to copy
in - source stream
out - destination stream
Throws:
java.io.IOException

copy

public static long copy(java.io.File src,
                        java.io.File dest)
                 throws java.io.IOException
Copy file.

Parameters:
src - source file
dest - destination file
Returns:
how much bytes were copied.
Throws:
java.io.IOException

copy

public static long copy(java.io.InputStream in,
                        java.io.OutputStream out)
                 throws java.io.IOException
copy data from in to out

Parameters:
in - source InputStream
out - destination OutputStream
Returns:
how much bytes were copied.
Throws:
java.io.IOException

copy

public static long copy(java.io.InputStream in,
                        java.io.DataOutput out)
                 throws java.io.IOException
copy data from source to destination stream

Parameters:
in - source stream
out - destination stream
Returns:
amount of copied bytes
Throws:
java.io.IOException

copy

public static long copy(RandomAccessInput in,
                        long offset,
                        java.io.OutputStream out)
                 throws java.io.IOException
copy data from in to out

Parameters:
in - source RandomAccessRO
offset - offset in in
out - destination OutputStream
Throws:
java.io.IOException

copy

public static long copy(RandomAccessInput in,
                        long offset,
                        java.io.DataOutput out)
                 throws java.io.IOException
copy data from source to destination stream

Parameters:
in - source stream
offset - offset in source stream
out - destination stream
Returns:
how much bytes was copied
Throws:
java.io.IOException

copy

public static long copy(long offset,
                        long length,
                        RandomAccessInput in,
                        java.io.OutputStream out)
                 throws java.io.IOException
copy data from source to destination stream

Parameters:
offset - offset in source stream
length - amount of bytes to copy
in - source stream
out - destination stream
Throws:
java.io.IOException

copy

public static long copy(long offset,
                        long length,
                        RandomAccessInput in,
                        java.io.DataOutput out)
                 throws java.io.IOException
copy data from source to destination stream

Parameters:
offset - offset in source stream
length - amount of bytes to copy
in - source stream
out - destination stream
Throws:
java.io.IOException

readShort

public static int readShort(java.io.InputStream in,
                            int byteOrder)
                     throws java.io.IOException
read big/little-endian short

Throws:
java.io.IOException

readShort

public static int readShort(java.io.DataInput in,
                            int byteOrder)
                     throws java.io.IOException
Throws:
java.io.IOException

readInt

public static int readInt(java.io.InputStream in,
                          int byteOrder)
                   throws java.io.IOException
read big/little-endian int

Throws:
java.io.IOException

readInt

public static int readInt(java.io.DataInput in,
                          int byteOrder)
                   throws java.io.IOException
read big/little-endian int

Throws:
java.io.IOException