public class NIOInputStream
extends java.io.InputStream
implements java.io.DataInput
| Modifier and Type | Field and Description | 
|---|---|
| protected java.nio.channels.Channel | channelThe file channel backed by the random access file. | 
| protected static int | DEFAULT_BLOCK_SIZEBlock size to use when searching through the stream. | 
| protected java.io.File | fileThe file. | 
| protected java.lang.String | filenameThe file name. | 
| protected boolean | isLittleEndianEndianness of the stream. | 
| protected static int | MAX_SEARCH_SIZEMaximum number of bytes to search when searching through the stream. | 
| protected IRandomAccess | raf | 
| Constructor and Description | 
|---|
| NIOInputStream(byte[] array)Constructs a random access stream around the given byte array. | 
| NIOInputStream(IRandomAccess handle)Constructs a random access stream around the given handle. | 
| NIOInputStream(java.lang.String filename)Constructs an NIOInputStream around the given file. | 
| Modifier and Type | Method and Description | 
|---|---|
| int | available() | 
| void | close()Closes the streams. | 
| java.lang.String | findString(boolean saveString,
          int blockSize,
          java.lang.String... terminators)Reads or skips a string ending with one of the given terminating
 substrings, using the specified block size for buffering. | 
| java.lang.String | findString(boolean saveString,
          java.lang.String... terminators)Reads or skips a string ending with
 one of the given terminating substrings. | 
| java.lang.String | findString(int blockSize,
          java.lang.String... terminators)Reads a string ending with one of the given terminating
 substrings, using the specified block size for buffering. | 
| java.lang.String | findString(java.lang.String... terminators)Reads a string ending with one of the given terminating substrings. | 
| long | getFilePointer()Gets the current (absolute) file pointer. | 
| java.io.DataInputStream | getInputStream()Returns the underlying InputStream. | 
| boolean | isLittleEndian()Gets the endianness of the stream. | 
| long | length()Gets the number of bytes in the file. | 
| void | mark(int readLimit) | 
| boolean | markSupported() | 
| void | order(boolean isLittleEndian)Sets the endianness of the stream. | 
| int | read()Alias for readByte(). | 
| int | read(byte[] array)Read bytes from the stream into the given array. | 
| int | read(byte[] array,
    int offset,
    int n)Read n bytes from the stream into the given array at the specified offset. | 
| boolean | readBoolean()Read an input byte and return true if the byte is nonzero. | 
| byte | readByte()Read one byte and return it. | 
| char | readChar()Read an input char. | 
| java.lang.String | readCString()Read a string of arbitrary length, terminated by a null char. | 
| double | readDouble()Read eight bytes and return a double value. | 
| float | readFloat()Read four bytes and return a float value. | 
| void | readFully(byte[] array)Read bytes from the stream into the given array. | 
| void | readFully(byte[] array,
         int offset,
         int n)Read n bytes from the stream into the given array at the specified offset. | 
| int | readInt()Read four input bytes and return an int value. | 
| java.lang.String | readLine()Read the next line of text from the input stream. | 
| long | readLong()Read eight input bytes and return a long value. | 
| short | readShort()Read two input bytes and return a short value. | 
| java.lang.String | readString(int n)Read a string of length n. | 
| java.lang.String | readString(java.lang.String lastChars)Reads a string ending with one of the characters in the given string. | 
| int | readUnsignedByte()Read an input byte and zero extend it appropriately. | 
| int | readUnsignedShort()Read two bytes and return an int in the range 0 through 65535. | 
| java.lang.String | readUTF()Read a string that has been encoded using a modified UTF-8 format. | 
| void | reset() | 
| void | seek(long pos)Seeks to the given offset within the stream. | 
| void | setExtend(int extend)Sets the number of bytes by which to extend the stream. | 
| int | skipBytes(int n)Skip n bytes within the stream. | 
protected static final int DEFAULT_BLOCK_SIZE
protected static final int MAX_SEARCH_SIZE
protected IRandomAccess raf
protected java.lang.String filename
protected java.io.File file
protected java.nio.channels.Channel channel
protected boolean isLittleEndian
public NIOInputStream(java.lang.String filename)
               throws java.io.IOException
java.io.IOExceptionpublic NIOInputStream(IRandomAccess handle)
public NIOInputStream(byte[] array)
public java.io.DataInputStream getInputStream()
public void setExtend(int extend)
public void seek(long pos)
          throws java.io.IOException
java.io.IOExceptionpublic int read()
         throws java.io.IOException
read in class java.io.InputStreamjava.io.IOExceptionpublic long length()
            throws java.io.IOException
java.io.IOExceptionpublic long getFilePointer()
public void close()
           throws java.io.IOException
close in interface java.io.Closeableclose in interface java.lang.AutoCloseableclose in class java.io.InputStreamjava.io.IOExceptionpublic void order(boolean isLittleEndian)
public boolean isLittleEndian()
public java.lang.String readString(java.lang.String lastChars)
                            throws java.io.IOException
java.io.IOExceptionfindString(String...)public java.lang.String findString(java.lang.String... terminators)
                            throws java.io.IOException
terminators - The strings for which to search.java.io.IOExceptionpublic java.lang.String findString(boolean saveString,
                          java.lang.String... terminators)
                            throws java.io.IOException
saveString - Whether to collect the string from the current file
   pointer to the terminating bytes, and return it. If false, returns null.terminators - The strings for which to search.java.io.IOException - If saveString flag is set
   and the maximum search length (512 MB) is exceeded.public java.lang.String findString(int blockSize,
                          java.lang.String... terminators)
                            throws java.io.IOException
blockSize - The block size to use when reading bytes in chunks.terminators - The strings for which to search.java.io.IOExceptionpublic java.lang.String findString(boolean saveString,
                          int blockSize,
                          java.lang.String... terminators)
                            throws java.io.IOException
saveString - Whether to collect the string from the current file
   pointer to the terminating bytes, and return it. If false, returns null.blockSize - The block size to use when reading bytes in chunks.terminators - The strings for which to search.java.io.IOException - If saveString flag is set
   and the maximum search length (512 MB) is exceeded.public boolean readBoolean()
                    throws java.io.IOException
readBoolean in interface java.io.DataInputjava.io.IOExceptionpublic byte readByte()
              throws java.io.IOException
readByte in interface java.io.DataInputjava.io.IOExceptionpublic char readChar()
              throws java.io.IOException
readChar in interface java.io.DataInputjava.io.IOExceptionpublic double readDouble()
                  throws java.io.IOException
readDouble in interface java.io.DataInputjava.io.IOExceptionpublic float readFloat()
                throws java.io.IOException
readFloat in interface java.io.DataInputjava.io.IOExceptionpublic int readInt()
            throws java.io.IOException
readInt in interface java.io.DataInputjava.io.IOExceptionpublic java.lang.String readLine()
                          throws java.io.IOException
readLine in interface java.io.DataInputjava.io.IOExceptionpublic java.lang.String readCString()
                             throws java.io.IOException
java.io.IOExceptionpublic java.lang.String readString(int n)
                            throws java.io.IOException
java.io.IOExceptionpublic long readLong()
              throws java.io.IOException
readLong in interface java.io.DataInputjava.io.IOExceptionpublic short readShort()
                throws java.io.IOException
readShort in interface java.io.DataInputjava.io.IOExceptionpublic int readUnsignedByte()
                     throws java.io.IOException
readUnsignedByte in interface java.io.DataInputjava.io.IOExceptionpublic int readUnsignedShort()
                      throws java.io.IOException
readUnsignedShort in interface java.io.DataInputjava.io.IOExceptionpublic java.lang.String readUTF()
                         throws java.io.IOException
readUTF in interface java.io.DataInputjava.io.IOExceptionpublic int skipBytes(int n)
              throws java.io.IOException
skipBytes in interface java.io.DataInputjava.io.IOExceptionpublic int read(byte[] array)
         throws java.io.IOException
read in class java.io.InputStreamjava.io.IOExceptionpublic int read(byte[] array,
       int offset,
       int n)
         throws java.io.IOException
read in class java.io.InputStreamjava.io.IOExceptionpublic void readFully(byte[] array)
               throws java.io.IOException
readFully in interface java.io.DataInputjava.io.IOExceptionpublic void readFully(byte[] array,
             int offset,
             int n)
               throws java.io.IOException
readFully in interface java.io.DataInputjava.io.IOExceptionpublic int available()
              throws java.io.IOException
available in class java.io.InputStreamjava.io.IOExceptionpublic void mark(int readLimit)
mark in class java.io.InputStreampublic boolean markSupported()
markSupported in class java.io.InputStreampublic void reset()
           throws java.io.IOException
reset in class java.io.InputStreamjava.io.IOExceptionCopyright © 2014 Open Microscopy Environment