public class TextFile
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
protected java.io.File |
textFile
The text file.
|
protected java.lang.String |
textFileEncoding
The text file encoding.
|
protected java.lang.String[] |
textFileLines
The text of the data file, split into lines.
|
protected boolean |
textFileLoaded
True if file loaded OK.
|
Constructor and Description |
---|
TextFile(java.io.File textFile)
Create text file object from local file.
|
TextFile(java.io.File textFile,
java.lang.String encoding)
Create text file object from file with specified encoding.
|
TextFile(java.io.InputStream inputStream)
Create data file object from input stream.
|
TextFile(java.io.InputStream inputStream,
java.lang.String encoding)
Create data file object from input stream.
|
TextFile(java.lang.String textFileName)
Create text file object from named file.
|
TextFile(java.lang.String textFileName,
java.lang.String encoding)
Create text file object from named file with specified encoding.
|
TextFile(java.net.URL url,
java.lang.String encoding)
Create data file object from URL.
|
Modifier and Type | Method and Description |
---|---|
protected void |
openFile(java.io.File inputFile)
Read local file into array of strings.
|
protected void |
openInputStream(java.io.InputStream inputStream)
Read stream into array of strings.
|
int |
size()
Return number of lines in the data file.
|
boolean |
textLoaded()
Did text load OK?
|
java.lang.String[] |
toArray()
Return file contents as a string array.
|
java.lang.String |
toString()
Return file contents as a string.
|
protected java.io.File textFile
protected java.lang.String textFileEncoding
protected java.lang.String[] textFileLines
protected boolean textFileLoaded
public TextFile(java.io.File textFile, java.lang.String encoding)
textFile
- Text file.encoding
- Text file encoding (utf-8, 8859_1, etc.).public TextFile(java.lang.String textFileName, java.lang.String encoding)
textFileName
- The data file name.encoding
- Text file encoding (utf-8, 8859_1, etc.).public TextFile(java.lang.String textFileName)
textFileName
- The data file name.public TextFile(java.io.File textFile)
textFile
- The data file.public TextFile(java.io.InputStream inputStream, java.lang.String encoding)
inputStream
- The input stream for the data file.encoding
- Text file encoding (utf-8, 8859_1, etc.).public TextFile(java.net.URL url, java.lang.String encoding)
url
- The input URL for the data file.encoding
- Text file encoding (utf-8, 8859_1, etc.).public TextFile(java.io.InputStream inputStream)
inputStream
- The input stream for the data file.protected void openFile(java.io.File inputFile)
inputFile
- The input file. The file is opened
using the urf-8 character set.protected void openInputStream(java.io.InputStream inputStream)
inputStream
- The InputStream for the file.public int size()
public boolean textLoaded()
public java.lang.String[] toArray()
public java.lang.String toString()
toString
in class java.lang.Object
Each line of the data file is separated by the platform line separator character in the returned string.