|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object edu.northwestern.at.utils.TextFile
public class TextFile
TextFile reads a text file into an array of strings.
Field Summary | |
---|---|
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 Summary | |
---|---|
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. |
Method Summary | |
---|---|
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. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected java.io.File textFile
protected java.lang.String textFileEncoding
protected java.lang.String[] textFileLines
protected boolean textFileLoaded
Constructor Detail |
---|
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.io.InputStream inputStream)
inputStream
- The input stream for the data file. Method Detail |
---|
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 a \n character in the returned string.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |