public final class FileText extends java.lang.Object
This class will be passed to instances of class FileSetCheck by Checker.
| Constructor and Description |
|---|
FileText(java.io.File file,
java.util.List<java.lang.String> lines)
Compatibility constructor.
|
FileText(java.io.File file,
java.lang.String charsetName)
Creates a new file text representation.
|
FileText(FileText fileText)
Copy constructor.
|
| Modifier and Type | Method and Description |
|---|---|
java.lang.String |
get(int lineNo)
Retrieves a line of the text by its number.
|
java.nio.charset.Charset |
getCharset()
Get the character set which was used to read the file.
|
java.io.File |
getFile()
Get the name of the file.
|
java.lang.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.
|
java.lang.String[] |
toLinesArray()
Returns an array of all lines.
|
public FileText(FileText fileText)
fileText - to make copy ofpublic FileText(java.io.File file, java.util.List<java.lang.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 terminatorsjava.lang.NullPointerException - if the lines array is nullpublic FileText(java.io.File file, java.lang.String charsetName) throws java.io.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 filejava.lang.NullPointerException - if the text is nulljava.io.IOException - if the file could not be readpublic java.lang.String get(int lineNo)
lineNo - the number of the line to get, starting at zeropublic java.io.File getFile()
public java.nio.charset.Charset getCharset()
null for a file reconstructed from its lines.public java.lang.CharSequence getFullText()
public java.lang.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 int size()
Copyright © 2001-2020. All Rights Reserved.