java.lang.Object | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| | - | - | java.io.Reader | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| | - | - | java.io.InputStreamReader | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| | - | - | java.io.FileReader | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Class for reading character files.
FileReader is meant for reading streams of characters. For reading streams of raw bytes, consider using a FileInputStream.
Constructor | Summary |
---|---|
FileReader(File file) | Creates a new FileReader, given the File to read from. |
FileReader(FileDescriptor fd) | Creates a new FileReader, given the FileDescriptor to read from. |
FileReader(String fileName) | Creates a new FileReader, given the name of the file to read from. |
Methods inherited from class java.io.InputStreamReader
Return | Method | Summary |
---|---|---|
void | close() | Closes the stream and releases any system resources associated with it. |
String | getEncoding() | Returns the name of the character encoding being used by this stream. |
int | read() | Reads a single character. The character read, or -1 if the end of the stream has been reached |
int | read(char[] cbuf, int offset, int length) | Reads characters into a portion of an array. The character read, or -1 if the end of the stream has been reached |
boolean | ready() | Tells whether this stream is ready to be read. |
Methods inherited from class java.io.Reader
Return | Method | Summary |
---|---|---|
void | mark(int readAheadLimit) | Marks the present position in the stream. |
boolean | markSupported() | Tells whether this stream supports the mark() operation. |
void | reset() | Resets the stream. |
long | skip(long n) | Skips characters. |
import java.io.FileReader;
public class Main {
public static void main(String[] argv) throws Exception {
FileReader fr = new FileReader("text.txt");
int ch;
do {
ch = fr.read();
if (ch != -1)
System.out.println((char) ch);
} while (ch != -1);
fr.close();
}
}
java2s.com | Contact Us | Privacy Policy |
Copyright 2009 - 12 Demo Source and Support. All rights reserved. |
All other trademarks are property of their respective owners. |