structure5
Class FileStream
java.lang.Object
java.io.InputStream
structure5.FileStream
- All Implemented Interfaces:
- java.io.Closeable
public class FileStream
- extends java.io.InputStream
This class provides a way to connect text files to scanners,
without worrying about Exceptions.
Typical usage:
FileStream input = new FileStream("data.txt");
Scanner scanner = new Scanner(input);
while (scanner.hasNextLine()) {
System.out.println(scanner.nextLine());
}
All the methods in this class are provided so that a Scanner can
read data from a file. You won't need to use them if you use a
Scanner to read files (which is highly recommended).
Constructor Summary |
FileStream(java.lang.String name)
Create a reader for the file with the given name. |
Methods inherited from class java.io.InputStream |
read, read |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
FileStream
public FileStream(java.lang.String name)
- Create a reader for the file with the given name.
FileStream input = new FileStream("data.txt");
available
public int available()
- Overrides:
available
in class java.io.InputStream
close
public void close()
- Specified by:
close
in interface java.io.Closeable
- Overrides:
close
in class java.io.InputStream
mark
public void mark(int readlimit)
- Overrides:
mark
in class java.io.InputStream
markSupported
public boolean markSupported()
- Overrides:
markSupported
in class java.io.InputStream
read
public int read()
- Specified by:
read
in class java.io.InputStream
reset
public void reset()
- Overrides:
reset
in class java.io.InputStream
skip
public long skip(long n)
- Overrides:
skip
in class java.io.InputStream
main
public static void main(java.lang.String[] args)