FileReader
open class FileReader : InputStreamReader
Convenience class for reading character files. The constructors of this class assume that the default character encoding and the default byte-buffer size are appropriate. To specify these values yourself, construct an InputStreamReader on a FileInputStream.
FileReader is meant for reading streams of characters. For reading streams of raw bytes, consider using a FileInputStream.
Summary
| Public constructors |
|
Creates a new FileReader, given the name of the file to read from.
|
|
Creates a new FileReader, given the File to read from.
|
|
Creates a new FileReader, given the FileDescriptor to read from.
|
| Inherited functions |
From class InputStreamReader
Unit |
close()
|
String! |
getEncoding()
Returns the name of the character encoding being used by this stream.
If the encoding has an historical name then that name is returned; otherwise the encoding's canonical name is returned.
If this instance was created with the constructor then the returned name, being unique for the encoding, may differ from the name passed to the constructor. This method will return null if the stream has been closed.
|
Int |
read()
Reads a single character.
|
Int |
read(cbuf: CharArray!, offset: Int, length: Int)
Reads characters into a portion of an array.
|
Boolean |
ready()
Tells whether this stream is ready to be read. An InputStreamReader is ready if its input buffer is not empty, or if bytes are available to be read from the underlying byte stream.
|
|
From class Reader
Unit |
mark(readAheadLimit: Int)
Marks the present position in the stream. Subsequent calls to reset() will attempt to reposition the stream to this point. Not all character-input streams support the mark() operation.
|
Boolean |
markSupported()
Tells whether this stream supports the mark() operation. The default implementation always returns false. Subclasses should override this method.
|
Int |
read(target: CharBuffer!)
Attempts to read characters into the specified character buffer. The buffer is used as a repository of characters as-is: the only changes made are the results of a put operation. No flipping or rewinding of the buffer is performed.
|
Int |
read(cbuf: CharArray!)
Reads characters into an array. This method will block until some input is available, an I/O error occurs, or the end of the stream is reached.
|
Unit |
reset()
Resets the stream. If the stream has been marked, then attempt to reposition it at the mark. If the stream has not been marked, then attempt to reset it in some way appropriate to the particular stream, for example by repositioning it to its starting point. Not all character-input streams support the reset() operation, and some support reset() without supporting mark().
|
Long |
skip(n: Long)
Skips characters. This method will block until some characters are available, an I/O error occurs, or the end of the stream is reached.
|
|
| Inherited properties |
From class Reader
Any! |
lock
The object used to synchronize operations on this stream. For efficiency, a character-stream object may use an object other than itself to protect critical sections. A subclass should therefore use the object in this field rather than this or a synchronized method.
|
|
Public constructors
<init>
FileReader(fileName: String!)
Creates a new FileReader, given the name of the file to read from.
| Parameters |
fileName |
String!: the name of the file to read from |
| Exceptions |
java.io.FileNotFoundException |
if the named file does not exist, is a directory rather than a regular file, or for some other reason cannot be opened for reading. |
<init>
FileReader(file: File!)
Creates a new FileReader, given the File to read from.
| Parameters |
file |
File!: the File to read from |
| Exceptions |
java.io.FileNotFoundException |
if the file does not exist, is a directory rather than a regular file, or for some other reason cannot be opened for reading. |
<init>
FileReader(fd: FileDescriptor!)
Creates a new FileReader, given the FileDescriptor to read from.