public class ManFileReadWriteExt
extends java.lang.Object
| Constructor and Description |
|---|
ManFileReadWriteExt() |
| Modifier and Type | Method and Description |
|---|---|
static void |
appendBytes(java.io.File thiz,
byte[] array)
Appends an [array] of bytes to the content of this file.
|
static void |
appendText(java.io.File thiz,
java.lang.String text)
Appends [text] to the content of this file using UTF-8 or the specified [charset].
|
static void |
appendText(java.io.File thiz,
java.lang.String text,
java.nio.charset.Charset charset) |
static java.io.BufferedReader |
bufferedReader(java.io.File thiz)
Returns a new [BufferedReader] for reading the content of this file.
|
static java.io.BufferedReader |
bufferedReader(java.io.File thiz,
java.nio.charset.Charset charset,
int bufferSize) |
static java.io.BufferedWriter |
bufferedWriter(java.io.File thiz)
Returns a new [BufferedWriter] for writing the content of this file.
|
static java.io.BufferedWriter |
bufferedWriter(java.io.File thiz,
java.nio.charset.Charset charset,
int bufferSize) |
static void |
forEachBlock(java.io.File thiz,
java.util.function.BiConsumer<byte[],java.lang.Integer> action)
Reads file by byte blocks and calls [action] for each block read.
|
static void |
forEachBlock(java.io.File thiz,
int blockSize,
java.util.function.BiConsumer<byte[],java.lang.Integer> action)
Reads file by byte blocks and calls [action] for each block read.
|
static void |
forEachLine(java.io.File thiz,
java.nio.charset.Charset charset,
java.util.function.Consumer<java.lang.String> action)
Reads this file line by line using the specified [charset] and calls [action] for each line.
|
static java.io.FileInputStream |
inputStream(java.io.File thiz)
Constructs a new FileInputStream of this file and returns it as a result.
|
static java.io.FileOutputStream |
outputStream(java.io.File thiz)
Constructs a new FileOutputStream of this file and returns it as a result.
|
static java.io.PrintWriter |
printWriter(java.io.File thiz)
Returns a new [PrintWriter] for writing the content of this file.
|
static java.io.PrintWriter |
printWriter(java.io.File thiz,
java.nio.charset.Charset charset) |
static byte[] |
readBytes(java.io.File thiz)
Gets the entire content of this file as a byte array.
|
static java.io.InputStreamReader |
reader(java.io.File thiz)
Returns a new [FileReader] for reading the content of this file.
|
static java.io.InputStreamReader |
reader(java.io.File thiz,
java.nio.charset.Charset charset) |
static java.util.List<java.lang.String> |
readLines(java.io.File thiz,
java.nio.charset.Charset charset)
Reads the file content as a list of lines.
|
static java.lang.String |
readText(java.io.File thiz)
Gets the entire content of this file as a String using UTF-8 or specified [charset].
|
static java.lang.String |
readText(java.io.File thiz,
java.nio.charset.Charset charset) |
static <T> T |
useLines(java.io.File thiz,
java.nio.charset.Charset charset,
java.util.function.Function<java.lang.Iterable<java.lang.String>,T> block)
Calls the [block] callback giving it a sequence of all the lines in this file and closes the reader once
the processing is complete.
|
static void |
writeBytes(java.io.File thiz,
byte[] array)
Sets the content of this file as an [array] of bytes.
|
static java.io.OutputStreamWriter |
writer(java.io.File thiz)
Returns a new [FileWriter] for writing the content of this file.
|
static java.io.OutputStreamWriter |
writer(java.io.File thiz,
java.nio.charset.Charset charset) |
static void |
writeText(java.io.File thiz,
java.lang.String text)
Sets the content of this file as [text] encoded using UTF-8 or specified [charset].
|
static void |
writeText(java.io.File thiz,
java.lang.String text,
java.nio.charset.Charset charset) |
public static java.io.InputStreamReader reader(java.io.File thiz)
public static java.io.InputStreamReader reader(java.io.File thiz,
java.nio.charset.Charset charset)
public static java.io.BufferedReader bufferedReader(java.io.File thiz)
bufferSize - necessary size of the buffer.public static java.io.BufferedReader bufferedReader(java.io.File thiz,
java.nio.charset.Charset charset,
int bufferSize)
public static java.io.OutputStreamWriter writer(java.io.File thiz)
public static java.io.OutputStreamWriter writer(java.io.File thiz,
java.nio.charset.Charset charset)
public static java.io.BufferedWriter bufferedWriter(java.io.File thiz)
bufferSize - necessary size of the buffer.public static java.io.BufferedWriter bufferedWriter(java.io.File thiz,
java.nio.charset.Charset charset,
int bufferSize)
public static java.io.PrintWriter printWriter(java.io.File thiz)
public static java.io.PrintWriter printWriter(java.io.File thiz,
java.nio.charset.Charset charset)
public static byte[] readBytes(java.io.File thiz)
This method is not recommended on huge files. It has an internal limitation of 2 GB byte array size.
public static void writeBytes(java.io.File thiz,
byte[] array)
array - byte array to write into this file.public static void appendBytes(java.io.File thiz,
byte[] array)
array - byte array to append to this file.public static java.lang.String readText(java.io.File thiz)
This method is not recommended on huge files. It has an internal limitation of 2 GB file size.
charset - character set to use.public static java.lang.String readText(java.io.File thiz,
java.nio.charset.Charset charset)
public static void writeText(java.io.File thiz,
java.lang.String text)
text - text to write into file.charset - character set to use.public static void writeText(java.io.File thiz,
java.lang.String text,
java.nio.charset.Charset charset)
public static void appendText(java.io.File thiz,
java.lang.String text)
text - text to append to file.charset - character set to use.public static void appendText(java.io.File thiz,
java.lang.String text,
java.nio.charset.Charset charset)
public static void forEachBlock(java.io.File thiz,
java.util.function.BiConsumer<byte[],java.lang.Integer> action)
You can use this function for huge files.
action - function to process file blocks.public static void forEachBlock(java.io.File thiz,
int blockSize,
java.util.function.BiConsumer<byte[],java.lang.Integer> action)
You can use this function for huge files.
action - function to process file blocks.blockSize - size of a block, replaced by 512 if it's less, 4096 by default.public static void forEachLine(java.io.File thiz,
java.nio.charset.Charset charset,
java.util.function.Consumer<java.lang.String> action)
You may use this function on huge files.
charset - character set to use.action - function to process file lines.public static java.io.FileInputStream inputStream(java.io.File thiz)
public static java.io.FileOutputStream outputStream(java.io.File thiz)
public static java.util.List<java.lang.String> readLines(java.io.File thiz,
java.nio.charset.Charset charset)
Do not use this function for huge files.
charset - character set to use. By default uses UTF-8 charset.public static <T> T useLines(java.io.File thiz,
java.nio.charset.Charset charset,
java.util.function.Function<java.lang.Iterable<java.lang.String>,T> block)
charset - character set to use. By default uses UTF-8 charset.Copyright © 2022. All rights reserved.