com.ibm.text.resources
Class ResourceReader
java.lang.Object
|
+--com.ibm.text.resources.ResourceReader
- public class ResourceReader
- extends java.lang.Object
A reader for text resource data in the current package. The
resource data is loaded through the class loader, so it will
typically be a file in the same directory as the *.class files, or
a file within a JAR file in the corresponding subdirectory. The
file must be a text file in one of the supported encodings; when the
resource is opened by constructing a ResourceReader
object the encoding is specified.
Although this class has a public API, it is designed for
internal use by classes in the com.ibm.text
package.
- Author:
- Alan Liu
Constructor Summary |
ResourceReader(java.lang.String resourceName)
Construct a reader object for the text file of the given name
in this package, using the default encoding. |
ResourceReader(java.lang.String resourceName,
java.lang.String encoding)
Construct a reader object for the text file of the given name
in this package, using the given encoding. |
Method Summary |
java.lang.String |
readLine()
Read and return the next line of the file or null
if the end of the file has been reached. |
void |
reset()
Reset this reader so that the next call to
readLine() returns the first line of the file
again. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ResourceReader
public ResourceReader(java.lang.String resourceName,
java.lang.String encoding)
throws java.io.UnsupportedEncodingException
- Construct a reader object for the text file of the given name
in this package, using the given encoding.
- Parameters:
resourceName
- the name of the text file located in this
packageencoding
- the encoding of the text file; if unsupported
an exception is thrown- Throws:
java.io.UnsupportedEncodingException
- if
encoding
is not supported by the JDK.
ResourceReader
public ResourceReader(java.lang.String resourceName)
- Construct a reader object for the text file of the given name
in this package, using the default encoding.
- Parameters:
resourceName
- the name of the text file located in this
package
readLine
public java.lang.String readLine()
throws java.io.IOException
- Read and return the next line of the file or
null
if the end of the file has been reached.
reset
public void reset()
- Reset this reader so that the next call to
readLine()
returns the first line of the file
again. This is a somewhat expensive call, however, calling
reset()
after calling it the first time does
nothing if readLine()
has not been called in
between.
Copyright (c) 2001 IBM Corporation and others.