| Constructor and Description |
|---|
FileText(File file,
List<String> lines)
Compatibility constructor.
|
FileText(File file,
String charsetName)
Creates a new file text representation.
|
FileText(FileText fileText)
Copy constructor.
|
| Modifier and Type | Method and Description |
|---|---|
String |
get(int lineNo)
Retrieves a line of the text by its number.
|
Charset |
getCharset()
Get the character set which was used to read the file.
|
File |
getFile()
Get the name of the file.
|
CharSequence |
getFullText()
Retrieve the full text of the file.
|
LineColumn |
lineColumn(int pos)
Determine line and column numbers in full text.
|
int |
size()
Counts the lines of the text.
|
String[] |
toLinesArray()
Returns an array of all lines.
|
public FileText(File file, String charsetName) throws IOException
The file will be read using the specified encoding, replacing malformed input and unmappable characters with the default replacement character.
file - the name of the filecharsetName - the encoding to use when reading the fileNullPointerException - if the text is nullIOException - if the file could not be readpublic FileText(FileText fileText)
fileText - to make copy ofpublic FileText(File file, List<String> lines)
This constructor reconstructs the text of the file by joining lines with linefeed characters. This process does not restore the original line terminators and should therefore be avoided.
file - the name of the filelines - the lines of the text, without terminatorsNullPointerException - if the lines array is nullpublic File getFile()
public Charset getCharset()
null for a file reconstructed from its lines.public CharSequence getFullText()
public String[] toLinesArray()
text.toLinesArray() is equivalent to
text.toArray(new String[text.size()]).public LineColumn lineColumn(int pos)
pos - the character position in the full textpublic String get(int lineNo)
lineNo - the number of the line to get, starting at zeropublic int size()
Copyright © 2001–2018. All rights reserved.