public class ResourceReader extends Object implements Closeable
ResourceReader
object the encoding is specified.
2015-sep-03 TODO: Only used in org.graalvm.shadowed.com.ibm.icu.dev.test.format, move there.
| Constructor and Description |
|---|
ResourceReader(Class<?> rootClass,
String resourceName)
Construct a reader object for the text file of the given name
in the given class's package, using the default encoding.
|
ResourceReader(Class<?> rootClass,
String resourceName,
String encoding)
Construct a reader object for the text file of the given name
in the given class's package, using the given encoding.
|
ResourceReader(InputStream is,
String resourceName)
Construct a reader object for the input stream associated with
the given resource name.
|
ResourceReader(InputStream is,
String resourceName,
String encoding)
Construct a reader object for the input stream associated with
the given resource name.
|
ResourceReader(String resourceName)
Construct a reader object for the text file of the given name
in this package, using the default encoding.
|
ResourceReader(String resourceName,
String encoding)
Construct a reader object for the text file of the given name
in this package, using the given encoding.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes the underlying reader and releases any system resources
associated with it.
|
String |
describePosition()
Return a string description of the position of the last line
returned by readLine() or readLineSkippingComments().
|
int |
getLineNumber()
Return the one-based line number of the last line returned by
readLine() or readLineSkippingComments().
|
String |
readLine()
Read and return the next line of the file or
null
if the end of the file has been reached. |
String |
readLineSkippingComments()
Read a line, ignoring blank lines and lines that start with
'#'.
|
String |
readLineSkippingComments(boolean trim)
Read a line, ignoring blank lines and lines that start with
'#'.
|
void |
reset()
Reset this reader so that the next call to
readLine() returns the first line of the file
again. |
public ResourceReader(String resourceName, String encoding) throws UnsupportedEncodingException
resourceName - the name of the text file located in this
package's ".data" subpackage.encoding - the encoding of the text file; if unsupported
an exception is thrownUnsupportedEncodingException - if
encoding is not supported by the JDK.public ResourceReader(String resourceName)
resourceName - the name of the text file located in this
package's ".data" subpackage.public ResourceReader(Class<?> rootClass, String resourceName, String encoding) throws UnsupportedEncodingException
resourceName - the name of the text file located in the
given class's package.encoding - the encoding of the text file; if unsupported
an exception is thrownUnsupportedEncodingException - if
encoding is not supported by the JDK.public ResourceReader(InputStream is, String resourceName, String encoding)
is - the input stream of the resourceresourceName - the name of the resourcepublic ResourceReader(InputStream is, String resourceName)
is - the input stream of the resourceresourceName - the name of the resourcepublic String readLine() throws IOException
null
if the end of the file has been reached.IOExceptionpublic String readLineSkippingComments(boolean trim) throws IOException
trim - if true then trim leading Pattern_White_Space.IOExceptionpublic String readLineSkippingComments() throws IOException
IOExceptionpublic int getLineNumber()
public String describePosition()
public void reset()
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.public void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableIOException