Package java.io
Class FileReader
- java.lang.Object
-
- java.io.Reader
-
- java.io.InputStreamReader
-
- java.io.FileReader
-
- All Implemented Interfaces:
Closeable,AutoCloseable,Readable
public class FileReader extends InputStreamReader
A specializedReaderthat reads from a file in the file system. All read requests made by calling methods in this class are directly forwarded to the equivalent function of the underlying operating system. Since this may induce some performance penalty, in particular if many small read requests are made, a FileReader is often wrapped by a BufferedReader.- See Also:
BufferedReader,FileWriter
-
-
Constructor Summary
Constructors Constructor Description FileReader(File file)Constructs a new FileReader on the givenfile.FileReader(FileDescriptor fd)Construct a new FileReader on the given FileDescriptorfd.FileReader(String filename)Construct a new FileReader on the given file namedfilename.
-
Method Summary
-
Methods inherited from class java.io.InputStreamReader
close, getEncoding, read, read, ready
-
-
-
-
Constructor Detail
-
FileReader
public FileReader(File file) throws FileNotFoundException
Constructs a new FileReader on the givenfile.- Parameters:
file- a File to be opened for reading characters from.- Throws:
FileNotFoundException- iffiledoes not exist.
-
FileReader
public FileReader(FileDescriptor fd)
Construct a new FileReader on the given FileDescriptorfd. Since a previously opened FileDescriptor is passed as an argument, no FileNotFoundException can be thrown.- Parameters:
fd- the previously opened file descriptor.
-
FileReader
public FileReader(String filename) throws FileNotFoundException
Construct a new FileReader on the given file namedfilename.- Parameters:
filename- an absolute or relative path specifying the file to open.- Throws:
FileNotFoundException- if there is no file namedfilename.
-
-