FileMethods
Provides extension methods for java.io.File
.
- See also:
PathMethods
Value members
Concrete methods
Appends contents of supplied InputStream to file.
Appends contents of supplied InputStream to file.
- Returns:
file
Appends contents of supplied Reader to file.
Appends contents of supplied Reader to file.
- Returns:
file
Appends supplied source to file.
Appends supplied source to file.
- Returns:
file
- Throws:
- IOException
if source is same as target
Filters lines in file using supplied predicate.
Filters lines in file using supplied predicate.
- Value parameters:
- p
predicate
Builds collection using elements mapped from files in directory.
Builds collection using elements mapped from files in directory.
- Value parameters:
- f
function
- Throws:
- java.io.IOException
if file is not directory or if directory listing is not available
Builds collection using elements mapped from lines in file.
Builds collection using elements mapped from lines in file.
- Value parameters:
- f
function
Folds files in directory to single value using given initial value and binary operator.
Folds files in directory to single value using given initial value and binary operator.
- Value parameters:
- init
initial value
- op
binary operator
- Returns:
init
if no files; otherwise, last value returned fromop
- Throws:
- java.io.IOException
if file is not directory or if directory listing is not available
Folds lines in file to single value using given initial value and binary operator.
Folds lines in file to single value using given initial value and binary operator.
- Value parameters:
- init
initial value
- op
binary operator
- Returns:
init
if file is empty; otherwise, last value returned fromop
Invokes supplied function for each file in directory.
Invokes supplied function for each file in directory.
- Value parameters:
- f
function
- Throws:
- java.io.IOException
if file is not directory or if directory listing is not available
Reads file and invokes supplied function for each line.
Reads file and invokes supplied function for each line.
The line content, excluding line separator, is passed to function.
- Value parameters:
- f
function
Maps each file in directory using supplied function.
Maps each file in directory using supplied function.
- Value parameters:
- f
function
- Throws:
- java.io.IOException
if file is not directory or if directory listing is not available
Maps each line in file using supplied function.
Maps each line in file using supplied function.
- Value parameters:
- f
function
Opens DataInput to file and passes it to supplied function. Underlying input stream is closed on function's return.
Opens DataInput to file and passes it to supplied function. Underlying input stream is closed on function's return.
- Value parameters:
- f
function
- Returns:
value from supplied function
Opens DataOutput to file and passes it to supplied function. Underlying output stream is closed on function's return.
Opens DataOutput to file and passes it to supplied function. Underlying output stream is closed on function's return.
- Value parameters:
- f
function
- Returns:
value from supplied function
Opens DataOutput to file and passes it to supplied function. Underlying output stream is closed on function's return.
Opens DataOutput to file and passes it to supplied function. Underlying output stream is closed on function's return.
- Value parameters:
- append
if
true
, output is appended to end of file; otherwise, iffalse
, file is truncated and output is written at beginning of file- f
function
- Returns:
value from supplied function
Opens InputStream to file and passes it to supplied function. Input stream is closed on function's return.
Opens InputStream to file and passes it to supplied function. Input stream is closed on function's return.
- Value parameters:
- f
function
- Returns:
value from supplied function
Opens OutputStream to file and passes it to supplied function. Output stream is closed on function's return.
Opens OutputStream to file and passes it to supplied function. Output stream is closed on function's return.
- Value parameters:
- f
function
- Returns:
value from supplied function
Opens OutputStream to file and passes it to supplied function. Output stream is closed on function's return.
Opens OutputStream to file and passes it to supplied function. Output stream is closed on function's return.
- Value parameters:
- append
if
true
, output is appended to end of file; otherwise, iffalse
, file is truncated and output is written at beginning of file- f
function
- Returns:
value from supplied function
Opens PrintWriter to file and passes it to supplied function. Writer is closed on function's return.
Opens PrintWriter to file and passes it to supplied function. Writer is closed on function's return.
- Value parameters:
- f
function
- Returns:
value from supplied function
Opens PrintWriter to file and passes it to supplied function. Writer is closed on function's return.
Opens PrintWriter to file and passes it to supplied function. Writer is closed on function's return.
- Value parameters:
- append
if
true
, output is appended to end of file; otherwise, iffalse
, file is truncated and output is written at beginning of file- f
function
- Returns:
value from supplied function
Opens RandomAccessFile with specified access mode and passes it to function. File is closed on function's return.
Opens RandomAccessFile with specified access mode and passes it to function. File is closed on function's return.
- Value parameters:
- f
function
- mode
access mode
- Returns:
value from supplied function
Opens BufferedReader to file and passes it to supplied function. Reader is closed on function's return.
Opens BufferedReader to file and passes it to supplied function. Reader is closed on function's return.
- Value parameters:
- f
function
- Returns:
value from supplied function
Opens BufferedWriter to file and passes it to supplied function. Writer is closed on function's return.
Opens BufferedWriter to file and passes it to supplied function. Writer is closed on function's return.
- Value parameters:
- f
function
- Returns:
value from supplied function
Opens BufferedWriter to file and passes it to supplied function. Writer is closed on function's return.
Opens BufferedWriter to file and passes it to supplied function. Writer is closed on function's return.
- Value parameters:
- append
if
true
, output is appended to end of file; otherwise, iffalse
, file is truncated and output is written at beginning of file- f
function
- Returns:
value from supplied function