structure5
Class FileStream
java.lang.Object
java.io.InputStream
structure5.FileStream
- All Implemented Interfaces:
- Closeable
public class FileStream
- extends 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(String name)
Create a reader for the file with the given name. |
FileStream
public FileStream(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 InputStream
close
public void close()
- Specified by:
close
in interface Closeable
- Overrides:
close
in class InputStream
mark
public void mark(int readlimit)
- Overrides:
mark
in class InputStream
markSupported
public boolean markSupported()
- Overrides:
markSupported
in class InputStream
read
public int read()
- Specified by:
read
in class InputStream
reset
public void reset()
- Overrides:
reset
in class InputStream
skip
public long skip(long n)
- Overrides:
skip
in class InputStream
main
public static void main(String[] args)