com.xce.io
Class FileInputStream

com.xce.io.FileInputStream

public class FileInputStream

The implementation of simple file input stream. This class privides functions to read from file.

You can open stdin(standard input stream) by a constructor:

new FileInputStream(XFile.STDIN);

And you can also open any file to read by following constructor:

new FileInputStream("FileName");


Constructor Summary
FileInputStream(int fd)
          A constructor to open STDIN(standard input stream).
FileInputStream(com.xce.io.String name)
          A constructor to open specified file to read.
FileInputStream(XFile file)
           
 
Method Summary
 int available()
          Checks how much bytes left to read.
 void close()
          Close this file.
 void mark(int readlimit)
          Mark current position for future use.
 boolean markSupported()
          FileInputStream supports mark. so this function always return true
 int read()
          Read a byte
 int read(byte[] b)
          same as read(b, 0, b.length)
 int read(byte[] b, int off, int len)
          Read from file to b with length len.
 void reset()
          Moves to marked position.
 long skip(long n)
          skip n bytes from file.
 

Constructor Detail

FileInputStream

public FileInputStream(int fd)
A constructor to open STDIN(standard input stream).
Parameters:
fd - must be FileInputStream.STDIN
Throws:
IllegalArgumentException - if fd is not STDIN

FileInputStream

public FileInputStream(com.xce.io.String name)
                throws java.io.IOException
A constructor to open specified file to read.
Parameters:
name - the file name to read.
Throws:
java.io.IOException -  

FileInputStream

public FileInputStream(XFile file)
                throws java.io.IOException
Method Detail

available

public int available()
              throws java.io.IOException
Checks how much bytes left to read.

close

public void close()
           throws java.io.IOException
Close this file.

mark

public void mark(int readlimit)
Mark current position for future use.

markSupported

public boolean markSupported()
FileInputStream supports mark. so this function always return true

read

public int read()
         throws java.io.IOException
Read a byte

read

public int read(byte[] b)
         throws java.io.IOException
same as read(b, 0, b.length)

read

public int read(byte[] b,
                int off,
                int len)
         throws java.io.IOException
Read from file to b with length len.
Returns:
the number of bytes to be read.

reset

public void reset()
           throws java.io.IOException
Moves to marked position.

skip

public long skip(long n)
          throws java.io.IOException
skip n bytes from file.
Returns:
the number of bytes to be skipped really.