java.io.File Extensions
Adds various functions to java.io.File
| Function Summary |
java.io.File
|
append(String text)
Appends text to the file.
|
String
|
getText()
Gets the contents of the file as a String.
|
void
|
eachLine(Function func)
Passes each line to the provided function.
|
String[]
|
getLines()
Collects the contents of the file as an array of lines.
|
boolean
|
remove()
Removes a file.
|
Functions
append
java.io.File append(String text)
Appends text to the file.
-
Example:
-
file.append("added text")
getText
String getText()
Gets the contents of the file as a String.
-
Example:
-
text = file.getText()
eachLine
void eachLine(Function func)
Passes each line to the provided function. The file is opened, and interpreted as a text file using the default encoding. Each line is read and passed to the provided function.
-
Example:
-
file.eachLine(function(line) { print(line) })
getLines
String[] getLines()
Collects the contents of the file as an array of lines. The file is opened, and interpreted as a text file using the default encoding.
-
Example:
-
linesArray = file.getLines()
remove
boolean remove()
Removes a file. Used to get around the problem of the reserved word 'delete'.
-
Example:
-
isRemoved = file.remove()