Class IOUtil
Note: This class includes codes copied from Apache Commons Lang, Apache Commons IO, Google Guava and other open source projects under the Apache License 2.0. The methods copied from other libraries/frameworks/projects may be modified in this class.
- Version:
- $Revision: 0.8 $
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
static final String
current path retrieved bynew File("./").getAbsolutePath()
static final int
static final String
static final String
static final boolean
static final boolean
static final boolean
static final boolean
static final boolean
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final JavaVersion
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final int
static final long
static final long
static final long
static final long
static final long
static final long
static final long
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
static void
static void
static void
static void
static void
static long
static long
static long
append
(File output, InputStream input) static long
append
(File output, InputStream input, long offset, long len) static long
static long
static long
static long
static void
append
(File output, CharSequence str) static void
append
(File output, CharSequence str, Charset charset) static void
appendLine
(File output, CharSequence str) static void
appendLine
(File output, CharSequence str, Charset charset) static char[]
bytes2Chars
(byte[] bytes) Bytes 2 chars.static char[]
bytes2Chars
(byte[] bytes, int offset, int len, Charset charset) Bytes 2 chars.static char[]
bytes2Chars
(byte[] bytes, Charset charset) Bytes 2 chars.static byte[]
chars2Bytes
(char[] chars) Chars 2 bytes.static byte[]
chars2Bytes
(char[] chars, int offset, int len, Charset charset) Chars 2 bytes.static byte[]
chars2Bytes
(char[] chars, Charset charset) Chars 2 bytes.static boolean
cleanDirectory
(File directory) Cleans a directory without deleting it.static void
close
(AutoCloseable closeable) static void
closeAll
(AutoCloseable... a) static void
closeAll
(Collection<? extends AutoCloseable> c) static void
closeAllQuietly
(AutoCloseable... a) Close all quietly.static void
closeAllQuietly
(Collection<? extends AutoCloseable> c) Close all quietly.static void
closeQuietly
(AutoCloseable closeable) static long
copy
(InputStream in, Path target, CopyOption... options) static long
copy
(Path source, OutputStream output) static Path
copy
(Path source, Path target, CopyOption... options) static void
copyFileToDirectory
(File srcFile, File destDir) static void
copyFileToDirectory
(File srcFile, File destDir, boolean preserveFileDate) static <E extends Exception>
voidcopyFileToDirectory
(File srcFile, File destDir, boolean preserveFileDate, Throwables.BiPredicate<? super File, ? super File, E> filter) Copy the specifiedscrFile
if it's a file or its sub files/directories if it's a directory to the targetdestDir
with the specifiedfilter
.static void
copyURLToFile
(URL source, File destination) Copies bytes from the URLsource
to a filedestination
.static void
copyURLToFile
(URL source, File destination, int connectionTimeout, int readTimeout) Copies bytes from the URLsource
to a filedestination
.static boolean
createIfNotExists
(File file) Creates the if not exists.static boolean
deleteAllIfExists
(File file) Delete the specified file and all its sub files/directories if it's a directory.static boolean
deleteFiles
(File dir) static <E extends Exception>
booleandeleteFiles
(File dir, Throwables.BiPredicate<? super File, ? super File, E> filter) Delete the specifieddir
if it's a file or its sub files/directories if it's a directory with the specified filter.static boolean
deleteIfExists
(File file) Delete the specified file (or directory).static long
Returns the disk size of the volume which holds the working directory.static long
freeDiskSpaceKb
(long timeout) Returns the disk size of the volume which holds the working directory.static long
freeDiskSpaceKb
(String path) Returns the free space on a drive or volume in kilobytes by invoking the command line.static long
freeDiskSpaceKb
(String path, long timeout) Returns the free space on a drive or volume in kilobytes by invoking the command line.static String
getFileExtension
(String fullName) Note: copied from Google Guava under Apache License v2.static String
Note: copied from Google Guava under Apache License v2.static boolean
isFileNewer
(File file, File reference) Tests if the specifiedFile
is newer than the referenceFile
.static boolean
isFileNewer
(File file, Date date) Tests if the specifiedFile
is newer than the specifiedDate
.static boolean
isFileOlder
(File file, File reference) Tests if the specifiedFile
is older than the referenceFile
.static boolean
isFileOlder
(File file, Date date) Tests if the specifiedFile
is older than the specifiedDate
.static boolean
isSymbolicLink
(File file) Determines whether the specified file is a Symbolic Link rather than an actual file.list
(File parentPath, boolean recursively, Throwables.BiPredicate<? super File, ? super File, E> filter) listDirectories
(File parentPath) listDirectories
(File parentPath, boolean recursively) listFiles
(File parentPath, boolean recursively, Throwables.BiPredicate<? super File, ? super File, E> filter) static MappedByteBuffer
Note: copied from Google Guava under Apache License v2.static MappedByteBuffer
map
(File file, FileChannel.MapMode mode) Note: copied from Google Guava under Apache License v2.static MappedByteBuffer
map
(File file, FileChannel.MapMode mode, long offset, long len) Note: copied from Google Guava under Apache License v2.static long
static long
merge
(Collection<File> sourceFiles, File destFile) Merge the specified source files into the destination file.static boolean
mkdirIfNotExists
(File dir) static boolean
mkdirsIfNotExists
(File dir) static void
static org.brotli.dec.BrotliInputStream
New GZIP input stream.static BufferedReader
newBufferedReader
(File file) New buffered reader.static BufferedReader
newBufferedReader
(File file, Charset charset) New buffered reader.static BufferedReader
New buffered reader.static BufferedReader
newBufferedReader
(InputStream is, Charset charset) New buffered reader.static BufferedReader
newBufferedReader
(Path path) New buffered reader.static BufferedReader
newBufferedReader
(Path path, Charset charset) New buffered reader.static BufferedWriter
newBufferedWriter
(File file) New buffered writer.static BufferedWriter
newBufferedWriter
(File file, Charset charset) New buffered writer.static BufferedWriter
New buffered writer.static BufferedWriter
newBufferedWriter
(OutputStream os, Charset charset) New buffered writer.static GZIPInputStream
New GZIP input stream.static GZIPInputStream
newGZIPInputStream
(InputStream is, int bufferSize) Creates a new input stream with the specified buffer size.static GZIPOutputStream
New GZIP output stream.static GZIPOutputStream
newGZIPOutputStream
(OutputStream os, int bufferSize) Creates a new input stream with the specified buffer size.static LZ4BlockInputStream
New LZ 4 block input stream.static LZ4BlockOutputStream
New LZ 4 block output stream.static LZ4BlockOutputStream
newLZ4BlockOutputStream
(OutputStream os, int blockSize) Creates a new input stream with the specified buffer size.static SnappyInputStream
New snappy input stream.static SnappyOutputStream
New snappy output stream.static SnappyOutputStream
newSnappyOutputStream
(OutputStream os, int bufferSize) Creates a new input stream with the specified buffer size.static <E extends Exception>
voidparse
(File file, int readThreadNum, int processThreadNum, int queueSize, Throwables.Consumer<String, E> lineParser) parse
(File file, int readThreadNum, int processThreadNum, int queueSize, Throwables.Consumer<String, E> lineParser, Throwables.Runnable<E2> onComplete) static <E extends Exception>
voidparse
(File file, long lineOffset, long count, int readThreadNum, int processThreadNum, int queueSize, Throwables.Consumer<String, E> lineParser) parse
(File file, long lineOffset, long count, int readThreadNum, int processThreadNum, int queueSize, Throwables.Consumer<String, E> lineParser, Throwables.Runnable<E2> onComplete) Parse the specified files/directory line by line.static <E extends Exception>
voidparse
(File file, long lineOffset, long count, int processThreadNum, int queueSize, Throwables.Consumer<String, E> lineParser) parse
(File file, long lineOffset, long count, int processThreadNum, int queueSize, Throwables.Consumer<String, E> lineParser, Throwables.Runnable<E2> onComplete) Parse the specified files/directory line by line.static <E extends Exception>
voidparse
(File file, long lineOffset, long count, Throwables.Consumer<String, E> lineParser) parse
(File file, long lineOffset, long count, Throwables.Consumer<String, E> lineParser, Throwables.Runnable<E2> onComplete) static <E extends Exception>
voidparse
(File file, Throwables.Consumer<String, E> lineParser) parse
(File file, Throwables.Consumer<String, E> lineParser, Throwables.Runnable<E2> onComplete) static <E extends Exception>
voidparse
(InputStream is, long lineOffset, long count, int processThreadNum, int queueSize, Throwables.Consumer<String, E> lineParser) parse
(InputStream is, long lineOffset, long count, int processThreadNum, int queueSize, Throwables.Consumer<String, E> lineParser, Throwables.Runnable<E2> onComplete) Parse the specified Reader line by line.static <E extends Exception>
voidparse
(InputStream is, long lineOffset, long count, Throwables.Consumer<String, E> lineParser) parse
(InputStream is, long lineOffset, long count, Throwables.Consumer<String, E> lineParser, Throwables.Runnable<E2> onComplete) static <E extends Exception>
voidparse
(InputStream is, Throwables.Consumer<String, E> lineParser) parse
(InputStream is, Throwables.Consumer<String, E> lineParser, Throwables.Runnable<E2> onComplete) static <E extends Exception>
voidparse
(Reader reader, long lineOffset, long count, int processThreadNum, int queueSize, Throwables.Consumer<String, E> lineParser) parse
(Reader reader, long lineOffset, long count, int processThreadNum, int queueSize, Throwables.Consumer<String, E> lineParser, Throwables.Runnable<E2> onComplete) Parse the specified Reader line by line.static <E extends Exception>
voidparse
(Reader reader, long lineOffset, long count, Throwables.Consumer<String, E> lineParser) parse
(Reader reader, long lineOffset, long count, Throwables.Consumer<String, E> lineParser, Throwables.Runnable<E2> onComplete) static <E extends Exception>
voidparse
(Reader reader, Throwables.Consumer<String, E> lineParser) parse
(Reader reader, Throwables.Consumer<String, E> lineParser, Throwables.Runnable<E2> onComplete) static <E extends Exception>
voidparse
(List<File> files, int readThreadNum, int processThreadNum, int queueSize, Throwables.Consumer<String, E> lineParser) parse
(List<File> files, int readThreadNum, int processThreadNum, int queueSize, Throwables.Consumer<String, E> lineParser, Throwables.Runnable<E2> onComplete) static <E extends Exception>
voidparse
(List<File> files, long lineOffset, long count, int readThreadNum, int processThreadNum, int queueSize, Throwables.Consumer<String, E> lineParser) parse
(List<File> files, long lineOffset, long count, int readThreadNum, int processThreadNum, int queueSize, Throwables.Consumer<String, E> lineParser, Throwables.Runnable<E2> onComplete) Parse the specified files/directory line by line.static <E extends Exception>
voidparse
(List<File> files, long lineOffset, long count, int processThreadNum, int queueSize, Throwables.Consumer<String, E> lineParser) parse
(List<File> files, long lineOffset, long count, int processThreadNum, int queueSize, Throwables.Consumer<String, E> lineParser, Throwables.Runnable<E2> onComplete) Parse the specified files/directory line by line.static <E extends Exception>
voidparse
(List<File> files, long lineOffset, long count, Throwables.Consumer<String, E> lineParser) parse
(List<File> files, long lineOffset, long count, Throwables.Consumer<String, E> lineParser, Throwables.Runnable<E2> onComplete) static <E extends Exception>
voidparse
(List<File> files, Throwables.Consumer<String, E> lineParser) parse
(List<File> files, Throwables.Consumer<String, E> lineParser, Throwables.Runnable<E2> onComplete) static int
static int
static int
static int
static int
static int
static int
read
(InputStream is, byte[] buf) static int
read
(InputStream is, byte[] buf, int off, int len) static int
static int
static byte[]
readAllBytes
(File file) static byte[]
static char[]
readAllChars
(File file) static char[]
readAllChars
(File file, Charset encoding) static char[]
static char[]
readAllChars
(InputStream is, Charset encoding) static char[]
readAllChars
(Reader reader) readAllLines
(File file) readAllLines
(File file, Charset encoding) readAllLines
(InputStream is, Charset encoding) readAllLines
(Reader reader) static byte[]
static byte[]
static byte[]
readBytes
(InputStream is) static byte[]
readBytes
(InputStream is, long offset, int maxLen) static char[]
static char[]
static char[]
static char[]
static char[]
readChars
(InputStream is) static char[]
readChars
(InputStream is, long offset, int maxLen) static char[]
readChars
(InputStream is, long offset, int maxLen, Charset encoding) static char[]
readChars
(InputStream is, Charset encoding) static char[]
static char[]
static String
static String
static String
static String
readLine
(InputStream is) static String
readLine
(InputStream is, int lineIndex) static String
readLine
(InputStream is, int lineIndex, Charset encoding) static String
static String
readLines
(InputStream is) readLines
(InputStream is, int offset, int count) readLines
(InputStream is, int offset, int count, Charset encoding) readLines
(InputStream is, Charset encoding) static String
readString
(File file) Read all content into oneString
.static String
readString
(File file, long offset, int maxLen) static String
readString
(File file, long offset, int maxLen, Charset encoding) static String
readString
(File file, Charset encoding) Read all content into oneString
.static String
Read all content into oneString
.static String
readString
(InputStream is, long offset, int maxLen) static String
readString
(InputStream is, long offset, int maxLen, Charset encoding) static String
readString
(InputStream is, Charset encoding) Read all content into oneString
.static String
readString
(Reader reader) Read all content into oneString
.static String
readString
(Reader reader, long offset, int maxLen) static boolean
static String
simplifyPath
(String pathname) Note: copied from Google Guava under Apache License v2.static long
Returns the size of the specified file or directory.static long
sizeOfDirectory
(File directory) Counts the size of a directory recursively (sum of the length of all files).static long
skip
(InputStream input, long toSkip) Return the count of skipped bytes.static long
Return the count of skipped chars.static void
skipFully
(InputStream input, long toSkip) static void
static void
static void
static void
splitBySize
(File file, long sizeOfPart) Split by size.static void
splitBySize
(File file, long sizeOfPart, File destDir) Mostly it's designed for (zipped/unzipped/log) text files.static InputStream
string2InputStream
(String str) String 2 input stream.static InputStream
string2InputStream
(String str, Charset charset) String 2 input stream.static Reader
string2Reader
(String str) String 2 reader.static Writer
String builder 2 writer.static File
Convert from aURL
to aFile
.static File[]
Converts each of an array ofURL
to aFile
.toFiles
(Collection<URL> urls) static boolean
Update the last modified time of the file to system current time if the specified file exists.static URL
static URL[]
To UR ls.toURLs
(Collection<File> files) To UR ls.static void
static void
static void
static void
static void
static void
static void
static long
static long
static long
write
(File output, InputStream input) static long
write
(File output, InputStream input, long offset, long len) static long
static long
static long
static long
static void
write
(File output, CharSequence str) static void
write
(File output, CharSequence str, Charset charset) static void
write
(OutputStream output, byte[] bytes) static void
write
(OutputStream output, byte[] bytes, boolean flush) static void
write
(OutputStream output, byte[] bytes, int offset, int len) static void
write
(OutputStream output, byte[] bytes, int offset, int len, boolean flush) static void
write
(OutputStream output, char[] chars) static void
write
(OutputStream output, char[] chars, boolean flush) static void
write
(OutputStream output, char[] chars, int offset, int len) static void
write
(OutputStream output, char[] chars, int offset, int len, boolean flush) static void
write
(OutputStream output, char[] chars, int offset, int len, Charset charset) static void
write
(OutputStream output, char[] chars, int offset, int len, Charset charset, boolean flush) static void
write
(OutputStream output, char[] chars, Charset charset) static long
write
(OutputStream output, File input) static long
write
(OutputStream output, File input, boolean flush) static long
write
(OutputStream output, File input, long offset, long len) static long
write
(OutputStream output, File input, long offset, long len, boolean flush) static long
write
(OutputStream output, InputStream input) static long
write
(OutputStream output, InputStream input, boolean flush) static long
write
(OutputStream output, InputStream input, long offset, long len) static long
write
(OutputStream output, InputStream input, long offset, long len, boolean flush) static void
write
(OutputStream output, CharSequence str) static void
write
(OutputStream output, CharSequence str, boolean flush) static void
write
(OutputStream output, CharSequence str, Charset charset) static void
write
(OutputStream output, CharSequence str, Charset charset, boolean flush) static void
static void
static void
static void
static void
static void
static void
static void
static void
static void
static void
static void
static void
static void
static void
static void
static void
static void
static void
static void
static long
static long
static long
static long
static long
static long
static long
static long
static void
write
(Writer output, CharSequence str) static void
write
(Writer output, CharSequence str, boolean flush) static void
static void
writeLine
(OutputStream os, Object obj) static void
writeLine
(OutputStream os, Object obj, boolean flush) static void
static void
static void
writeLines
(File file, Object[] lines) static void
writeLines
(File file, Object[] lines, int offset, int count) static void
writeLines
(File file, Collection<?> lines) static void
writeLines
(File file, Collection<?> lines, int offset, int count) static void
writeLines
(OutputStream os, Object[] lines) static void
writeLines
(OutputStream os, Object[] lines, boolean flush) static void
writeLines
(OutputStream os, Object[] lines, int offset, int count) static void
writeLines
(OutputStream os, Object[] lines, int offset, int count, boolean flush) static void
writeLines
(OutputStream os, Collection<?> lines) static void
writeLines
(OutputStream os, Collection<?> lines, boolean flush) static void
writeLines
(OutputStream os, Collection<?> lines, int offset, int count) static void
writeLines
(OutputStream os, Collection<?> lines, int offset, int count, boolean flush) static void
writeLines
(Writer writer, Object[] lines) static void
writeLines
(Writer writer, Object[] lines, boolean flush) static void
writeLines
(Writer writer, Object[] lines, int offset, int count) static void
writeLines
(Writer writer, Object[] lines, int offset, int count, boolean flush) static void
writeLines
(Writer writer, Collection<?> lines) static void
writeLines
(Writer writer, Collection<?> lines, boolean flush) static void
writeLines
(Writer writer, Collection<?> lines, int offset, int count) static void
writeLines
(Writer writer, Collection<?> lines, int offset, int count, boolean flush) static void
static void
zip
(Collection<File> sourceFiles, File targetFile)
-
Field Details
-
HOST_NAME
-
CPU_CORES
public static final int CPU_CORES -
ONE_KB
public static final long ONE_KB- See Also:
-
ONE_MB
public static final long ONE_MB- See Also:
-
ONE_GB
public static final long ONE_GB- See Also:
-
ONE_TB
public static final long ONE_TB- See Also:
-
ONE_PB
public static final long ONE_PB- See Also:
-
ONE_EB
public static final long ONE_EB- See Also:
-
ONE_ZB
public static final long ONE_ZB- See Also:
-
MAX_MEMORY_IN_MB
public static final int MAX_MEMORY_IN_MB -
OS_NAME
-
OS_VERSION
-
OS_ARCH
-
IS_OS_WINDOWS
public static final boolean IS_OS_WINDOWS -
IS_OS_MAC
public static final boolean IS_OS_MAC -
IS_OS_MAC_OSX
public static final boolean IS_OS_MAC_OSX -
IS_OS_LINUX
public static final boolean IS_OS_LINUX -
IS_PLATFORM_ANDROID
public static final boolean IS_PLATFORM_ANDROID -
JAVA_HOME
-
JAVA_VERSION
-
JAVA_VENDOR
-
JAVA_CLASS_PATH
-
JAVA_CLASS_VERSION
-
JAVA_RUNTIME_NAME
-
JAVA_RUNTIME_VERSION
-
JAVA_SPECIFICATION_NAME
-
JAVA_SPECIFICATION_VENDOR
-
JAVA_SPECIFICATION_VERSION
-
JAVA_VM_INFO
-
JAVA_VM_NAME
-
JAVA_VM_SPECIFICATION_NAME
-
JAVA_VM_SPECIFICATION_VENDOR
-
JAVA_VM_SPECIFICATION_VERSION
-
JAVA_VM_VENDOR
-
JAVA_VM_VERSION
-
JAVA_IO_TMPDIR
-
USER_DIR
-
USER_HOME
-
USER_NAME
-
USER_TIMEZONE
-
USER_LANGUAGE
-
USER_COUNTRY
-
CURRENT_PATH
current path retrieved bynew File("./").getAbsolutePath()
-
PATH_SEPARATOR
-
FILE_SEPARATOR
-
LINE_SEPARATOR
-
EOF
public static final int EOF- See Also:
-
-
Method Details
-
freeDiskSpaceKb
Returns the disk size of the volume which holds the working directory.Identical to:
freeSpaceKb(new File(".").getAbsolutePath())
- Returns:
- Throws:
UncheckedIOException
- if an error occurs when finding the free spaceIllegalStateException
- if an error occurred in initialisation
-
freeDiskSpaceKb
Returns the disk size of the volume which holds the working directory.Identical to:
freeSpaceKb(new File(".").getAbsolutePath())
- Parameters:
timeout
- The timeout amount in milliseconds or no timeout if the value is zero or less- Returns:
- Throws:
UncheckedIOException
- if an error occurs when finding the free spaceIllegalStateException
- if an error occurred in initialisation
-
freeDiskSpaceKb
Returns the free space on a drive or volume in kilobytes by invoking the command line.FileSystemUtils.freeSpaceKb("C:"); // Windows FileSystemUtils.freeSpaceKb("/volume"); // *nix
The free space is calculated via the command line. It uses 'dir /-c' on Windows, 'df -kP' on AIX/HP-UX and 'df -k' on other Unix.In order to work, you must be running Windows, or have a implementation of Unix df that supports GNU format when passed -k (or -kP). If you are going to rely on this code, please check that it works on your OS by running some simple tests to compare the command line with the output from this class. If your operating system isn't supported, please raise a JIRA call detailing the exact result from df -k and as much other detail as possible, thanks.
- Parameters:
path
- the path to get free space for, not null, not empty on Unix- Returns:
- Throws:
UncheckedIOException
- if an error occurs when finding the free spaceIllegalArgumentException
- if the path is invalidIllegalStateException
- if an error occurred in initialisation
-
freeDiskSpaceKb
Returns the free space on a drive or volume in kilobytes by invoking the command line.FileSystemUtils.freeSpaceKb("C:"); // Windows FileSystemUtils.freeSpaceKb("/volume"); // *nix
The free space is calculated via the command line. It uses 'dir /-c' on Windows, 'df -kP' on AIX/HP-UX and 'df -k' on other Unix.In order to work, you must be running Windows, or have a implementation of Unix df that supports GNU format when passed -k (or -kP). If you are going to rely on this code, please check that it works on your OS by running some simple tests to compare the command line with the output from this class. If your operating system isn't supported, please raise a JIRA call detailing the exact result from df -k and as much other detail as possible, thanks.
- Parameters:
path
- the path to get free space for, not null, not empty on Unixtimeout
- The timeout amount in milliseconds or no timeout if the value is zero or less- Returns:
- Throws:
UncheckedIOException
- if an error occurs when finding the free spaceIllegalArgumentException
- if the path is invalidIllegalStateException
- if an error occurred in initialisation
-
chars2Bytes
public static byte[] chars2Bytes(char[] chars) Chars 2 bytes.- Parameters:
chars
-- Returns:
-
chars2Bytes
Chars 2 bytes.- Parameters:
chars
-charset
-- Returns:
-
chars2Bytes
Chars 2 bytes.- Parameters:
chars
-offset
-len
-charset
-- Returns:
-
bytes2Chars
public static char[] bytes2Chars(byte[] bytes) Bytes 2 chars.- Parameters:
bytes
-- Returns:
-
bytes2Chars
Bytes 2 chars.- Parameters:
bytes
-charset
-- Returns:
-
bytes2Chars
Bytes 2 chars.- Parameters:
bytes
-offset
-len
-charset
-- Returns:
-
string2InputStream
String 2 input stream.- Parameters:
str
-- Returns:
-
string2InputStream
String 2 input stream.- Parameters:
str
-charset
-- Returns:
-
string2Reader
String 2 reader.- Parameters:
str
-- Returns:
-
stringBuilder2Writer
String builder 2 writer.- Parameters:
sb
-- Returns:
-
readAllBytes
- Parameters:
file
-- Returns:
- Throws:
UncheckedIOException
- the unchecked IO exception
-
readAllBytes
- Parameters:
is
-- Returns:
- Throws:
UncheckedIOException
- the unchecked IO exception
-
readBytes
- Parameters:
file
-- Returns:
- Throws:
IOException
- the unchecked IO exception- See Also:
-
readBytes
- Parameters:
file
-offset
-maxLen
-- Returns:
- Throws:
IOException
-
readBytes
- Parameters:
is
-- Returns:
- Throws:
IOException
- See Also:
-
readBytes
- Parameters:
is
-offset
-maxLen
-- Returns:
- Throws:
IOException
-
readAllChars
- Parameters:
file
-- Returns:
- Throws:
UncheckedIOException
- the unchecked IO exception
-
readAllChars
- Parameters:
file
-encoding
-- Returns:
- Throws:
UncheckedIOException
- the unchecked IO exception
-
readAllChars
- Parameters:
is
-- Returns:
- Throws:
UncheckedIOException
- the unchecked IO exception
-
readAllChars
- Parameters:
is
-encoding
-- Returns:
- Throws:
UncheckedIOException
- the unchecked IO exception
-
readAllChars
- Parameters:
reader
-- Returns:
- Throws:
UncheckedIOException
- the unchecked IO exception
-
readChars
- Parameters:
file
-- Returns:
- Throws:
IOException
- See Also:
-
readChars
- Parameters:
file
-encoding
-- Returns:
- Throws:
IOException
- See Also:
-
readChars
- Parameters:
file
-offset
-maxLen
-- Returns:
- Throws:
IOException
-
readChars
public static char[] readChars(File file, long offset, int maxLen, Charset encoding) throws IOException - Parameters:
file
-offset
-maxLen
-encoding
-- Returns:
- Throws:
IOException
-
readChars
- Parameters:
is
-- Returns:
- Throws:
IOException
- See Also:
-
readChars
- Parameters:
is
-encoding
-- Returns:
- Throws:
IOException
- See Also:
-
readChars
- Parameters:
is
-offset
-maxLen
-- Returns:
- Throws:
IOException
-
readChars
public static char[] readChars(InputStream is, long offset, int maxLen, Charset encoding) throws IOException - Parameters:
is
-offset
-maxLen
-encoding
-- Returns:
- Throws:
IOException
-
readChars
- Parameters:
reader
-- Returns:
- Throws:
IOException
- See Also:
-
readChars
- Parameters:
reader
-offset
-maxLen
-- Returns:
- Throws:
IOException
-
readString
Read all content into oneString
.- Parameters:
file
-- Returns:
- Throws:
UncheckedIOException
- the unchecked IO exception
-
readString
Read all content into oneString
.- Parameters:
file
-encoding
-- Returns:
- Throws:
UncheckedIOException
- the unchecked IO exception
-
readString
- Parameters:
file
-offset
-maxLen
-- Returns:
- Throws:
UncheckedIOException
- the unchecked IO exception
-
readString
public static String readString(File file, long offset, int maxLen, Charset encoding) throws UncheckedIOException - Parameters:
file
-offset
-maxLen
-encoding
-- Returns:
- Throws:
UncheckedIOException
- the unchecked IO exception
-
readString
Read all content into oneString
.- Parameters:
is
-- Returns:
- Throws:
UncheckedIOException
- the unchecked IO exception
-
readString
Read all content into oneString
.- Parameters:
is
-encoding
-- Returns:
- Throws:
UncheckedIOException
- the unchecked IO exception
-
readString
public static String readString(InputStream is, long offset, int maxLen) throws UncheckedIOException - Parameters:
is
-offset
-maxLen
-- Returns:
- Throws:
UncheckedIOException
- the unchecked IO exception
-
readString
public static String readString(InputStream is, long offset, int maxLen, Charset encoding) throws UncheckedIOException - Parameters:
is
-offset
-maxLen
-encoding
-- Returns:
- Throws:
UncheckedIOException
- the unchecked IO exception
-
readString
Read all content into oneString
.- Parameters:
reader
-- Returns:
- Throws:
UncheckedIOException
- the unchecked IO exception
-
readString
- Parameters:
reader
-offset
-maxLen
-- Returns:
- Throws:
UncheckedIOException
- the unchecked IO exception
-
readAllLines
- Parameters:
file
-- Returns:
- Throws:
UncheckedIOException
- the unchecked IO exception
-
readAllLines
- Parameters:
file
-encoding
-- Returns:
- Throws:
UncheckedIOException
- the unchecked IO exception
-
readAllLines
- Parameters:
is
-- Returns:
- Throws:
UncheckedIOException
- the unchecked IO exception
-
readAllLines
public static List<String> readAllLines(InputStream is, Charset encoding) throws UncheckedIOException - Parameters:
is
-encoding
-- Returns:
- Throws:
UncheckedIOException
- the unchecked IO exception
-
readAllLines
- Parameters:
reader
-- Returns:
- Throws:
UncheckedIOException
- the unchecked IO exception
-
readLine
- Parameters:
file
-- Returns:
- Throws:
IOException
-
readLine
- Parameters:
file
-lineIndex
-- Returns:
- Throws:
IOException
-
readLine
- Parameters:
file
-lineIndex
-encoding
-- Returns:
- Throws:
IOException
-
readLine
- Parameters:
is
-- Returns:
- Throws:
IOException
-
readLine
- Parameters:
is
-lineIndex
-- Returns:
- Throws:
IOException
-
readLine
- Parameters:
is
-lineIndex
-encoding
-- Returns:
- Throws:
IOException
-
readLine
- Parameters:
reader
-- Returns:
- Throws:
IOException
-
readLine
- Parameters:
reader
-lineIndex
-- Returns:
- Throws:
IOException
-
readLines
- Parameters:
file
-- Returns:
- Throws:
IOException
- See Also:
-
readLines
- Parameters:
file
-encoding
-- Returns:
- Throws:
IOException
- See Also:
-
readLines
- Parameters:
file
-offset
-count
-- Returns:
- Throws:
IOException
-
readLines
public static List<String> readLines(File file, int offset, int count, Charset encoding) throws IOException - Parameters:
file
-offset
-count
-encoding
-- Returns:
- Throws:
IOException
-
readLines
- Parameters:
is
-- Returns:
- Throws:
IOException
- See Also:
-
readLines
- Parameters:
is
-encoding
-- Returns:
- Throws:
IOException
- See Also:
-
readLines
- Parameters:
is
-offset
-count
-- Returns:
- Throws:
IOException
-
readLines
public static List<String> readLines(InputStream is, int offset, int count, Charset encoding) throws IOException - Parameters:
is
-offset
-count
-encoding
-- Returns:
- Throws:
IOException
-
readLines
- Parameters:
reader
-- Returns:
- Throws:
IOException
- See Also:
-
readLines
- Parameters:
reader
-offset
-count
-- Returns:
- Throws:
IOException
-
read
- Parameters:
file
-buf
-- Returns:
- Throws:
IOException
-
read
- Parameters:
file
-buf
-off
- the start offset in arrayb
at which the data is written.len
-- Returns:
- Throws:
IOException
-
read
- Parameters:
is
-buf
-- Returns:
- Throws:
IOException
- Signals that an I/O exception has occurred.
-
read
- Parameters:
is
-buf
-off
- the start offset in arrayb
at which the data is written.len
-- Returns:
- Throws:
IOException
- Signals that an I/O exception has occurred.
-
read
- Parameters:
file
-buf
-- Returns:
- Throws:
IOException
-
read
- Parameters:
file
-buf
-charset
-- Returns:
- Throws:
IOException
-
read
- Parameters:
file
-buf
-off
- the start offset in arrayb
at which the data is written.len
-- Returns:
- Throws:
IOException
-
read
- Parameters:
file
-buf
-off
-len
-charset
-- Returns:
- Throws:
IOException
-
read
- Parameters:
reader
-buf
-- Returns:
- Throws:
IOException
- Signals that an I/O exception has occurred.
-
read
- Parameters:
reader
-buf
-off
- the start offset in arrayb
at which the data is written.len
-- Returns:
- Throws:
IOException
- Signals that an I/O exception has occurred.
-
writeLine
- Parameters:
file
-obj
-- Throws:
IOException
-
writeLine
- Parameters:
os
-obj
-- Throws:
IOException
-
writeLine
- Parameters:
os
-obj
-flush
-- Throws:
IOException
-
writeLine
- Parameters:
writer
-obj
-- Throws:
IOException
-
writeLine
- Parameters:
writer
-obj
-flush
-- Throws:
IOException
-
writeLines
- Parameters:
file
-lines
-- Throws:
IOException
-
writeLines
- Parameters:
file
-lines
-offset
-count
-- Throws:
IOException
-
writeLines
- Parameters:
os
-lines
-- Throws:
IOException
-
writeLines
- Parameters:
os
-lines
-flush
-- Throws:
IOException
-
writeLines
public static void writeLines(OutputStream os, Object[] lines, int offset, int count) throws IOException - Parameters:
os
-lines
-offset
-count
-- Throws:
IOException
-
writeLines
public static void writeLines(OutputStream os, Object[] lines, int offset, int count, boolean flush) throws IOException - Parameters:
os
-lines
-offset
-count
-flush
-- Throws:
IOException
-
writeLines
- Parameters:
writer
-lines
-- Throws:
IOException
-
writeLines
- Parameters:
writer
-lines
-flush
-- Throws:
IOException
-
writeLines
public static void writeLines(Writer writer, Object[] lines, int offset, int count) throws IOException - Parameters:
writer
-lines
-offset
-count
-- Throws:
IOException
-
writeLines
public static void writeLines(Writer writer, Object[] lines, int offset, int count, boolean flush) throws IOException - Parameters:
writer
-lines
-offset
-count
-flush
-- Throws:
IOException
-
writeLines
- Parameters:
file
-lines
-- Throws:
IOException
-
writeLines
public static void writeLines(File file, Collection<?> lines, int offset, int count) throws IOException - Parameters:
file
-lines
-offset
-count
-- Throws:
IOException
-
writeLines
- Parameters:
os
-lines
-- Throws:
IOException
-
writeLines
public static void writeLines(OutputStream os, Collection<?> lines, boolean flush) throws IOException - Parameters:
os
-lines
-flush
-- Throws:
IOException
-
writeLines
public static void writeLines(OutputStream os, Collection<?> lines, int offset, int count) throws IOException - Parameters:
os
-lines
-offset
-count
-- Throws:
IOException
-
writeLines
public static void writeLines(OutputStream os, Collection<?> lines, int offset, int count, boolean flush) throws IOException - Parameters:
os
-lines
-offset
-count
-flush
-- Throws:
IOException
-
writeLines
- Parameters:
writer
-lines
-- Throws:
IOException
-
writeLines
- Parameters:
writer
-lines
-flush
-- Throws:
IOException
-
writeLines
public static void writeLines(Writer writer, Collection<?> lines, int offset, int count) throws IOException - Parameters:
writer
-lines
-offset
-count
-- Throws:
IOException
-
writeLines
public static void writeLines(Writer writer, Collection<?> lines, int offset, int count, boolean flush) throws IOException - Parameters:
writer
-lines
-offset
-count
-flush
-- Throws:
IOException
-
write
- Parameters:
writer
-b
-- Throws:
IOException
- Signals that an I/O exception has occurred.
-
write
- Parameters:
writer
-b
-flush
-- Throws:
IOException
- Signals that an I/O exception has occurred.
-
write
- Parameters:
writer
-c
-- Throws:
IOException
- Signals that an I/O exception has occurred.
-
write
- Parameters:
writer
-c
-flush
-- Throws:
IOException
- Signals that an I/O exception has occurred.
-
write
- Parameters:
writer
-b
-- Throws:
IOException
- Signals that an I/O exception has occurred.
-
write
- Parameters:
writer
-b
-flush
-- Throws:
IOException
- Signals that an I/O exception has occurred.
-
write
- Parameters:
writer
-s
-- Throws:
IOException
- Signals that an I/O exception has occurred.
-
write
- Parameters:
writer
-s
-flush
-- Throws:
IOException
- Signals that an I/O exception has occurred.
-
write
- Parameters:
writer
-i
-- Throws:
IOException
- Signals that an I/O exception has occurred.
-
write
- Parameters:
writer
-i
-flush
-- Throws:
IOException
- Signals that an I/O exception has occurred.
-
write
- Parameters:
writer
-lng
-- Throws:
IOException
- Signals that an I/O exception has occurred.
-
write
- Parameters:
writer
-lng
-flush
-- Throws:
IOException
- Signals that an I/O exception has occurred.
-
write
- Parameters:
writer
-f
-- Throws:
IOException
- Signals that an I/O exception has occurred.
-
write
- Parameters:
writer
-f
-flush
-- Throws:
IOException
- Signals that an I/O exception has occurred.
-
write
- Parameters:
writer
-d
-- Throws:
IOException
- Signals that an I/O exception has occurred.
-
write
- Parameters:
writer
-d
-flush
-- Throws:
IOException
- Signals that an I/O exception has occurred.
-
write
- Parameters:
output
-str
-- Throws:
IOException
-
write
- Parameters:
output
-str
-charset
-- Throws:
IOException
-
write
- Parameters:
output
-str
-- Throws:
IOException
-
write
- Parameters:
output
-str
-charset
-- Throws:
IOException
-
write
- Parameters:
output
-str
-flush
-- Throws:
IOException
-
write
public static void write(OutputStream output, CharSequence str, Charset charset, boolean flush) throws IOException - Parameters:
output
-str
-charset
-flush
-- Throws:
IOException
-
write
- Parameters:
output
-str
-- Throws:
IOException
-
write
- Parameters:
output
-str
-flush
-- Throws:
IOException
-
write
- Parameters:
output
-chars
-- Throws:
IOException
-
write
- Parameters:
output
-chars
-charset
-- Throws:
IOException
-
write
- Parameters:
output
-chars
-offset
-len
-- Throws:
IOException
-
write
public static void write(File output, char[] chars, int offset, int len, Charset charset) throws IOException - Parameters:
output
-chars
-offset
-len
-charset
-- Throws:
IOException
-
write
- Parameters:
output
-chars
-- Throws:
IOException
-
write
- Parameters:
output
-chars
-charset
-- Throws:
IOException
-
write
- Parameters:
output
-chars
-offset
-len
-- Throws:
IOException
-
write
public static void write(OutputStream output, char[] chars, int offset, int len, Charset charset) throws IOException - Parameters:
output
-chars
-offset
-len
-charset
-- Throws:
IOException
-
write
- Parameters:
output
-chars
-flush
-- Throws:
IOException
-
write
public static void write(OutputStream output, char[] chars, int offset, int len, boolean flush) throws IOException - Parameters:
output
-chars
-offset
-len
-flush
-- Throws:
IOException
-
write
public static void write(OutputStream output, char[] chars, int offset, int len, Charset charset, boolean flush) throws IOException - Parameters:
output
-chars
-offset
-len
-charset
-flush
-- Throws:
IOException
-
write
- Parameters:
output
-chars
-- Throws:
IOException
-
write
- Parameters:
output
-chars
-offset
-len
-- Throws:
IOException
-
write
- Parameters:
output
-chars
-flush
-- Throws:
IOException
-
write
public static void write(Writer output, char[] chars, int offset, int len, boolean flush) throws IOException - Parameters:
output
-chars
-offset
-len
-flush
-- Throws:
IOException
-
write
- Parameters:
output
-bytes
-- Throws:
IOException
-
write
- Parameters:
output
-bytes
-offset
-len
-- Throws:
IOException
-
write
- Parameters:
output
-bytes
-- Throws:
IOException
-
write
- Parameters:
output
-bytes
-offset
-len
-- Throws:
IOException
-
write
- Parameters:
output
-bytes
-flush
-- Throws:
IOException
-
write
public static void write(OutputStream output, byte[] bytes, int offset, int len, boolean flush) throws IOException - Parameters:
output
-bytes
-offset
-len
-flush
-- Throws:
IOException
-
write
- Parameters:
output
-input
-- Returns:
- Throws:
IOException
-
write
- Parameters:
output
-input
-offset
- by bytelen
- by byte- Returns:
- Throws:
IOException
-
write
- Parameters:
output
-input
-- Returns:
- Throws:
IOException
-
write
public static long write(OutputStream output, InputStream input, long offset, long len) throws IOException - Parameters:
output
-input
-offset
-len
-- Returns:
- Throws:
IOException
-
write
- Parameters:
output
-input
-flush
-- Returns:
- Throws:
IOException
-
write
public static long write(OutputStream output, InputStream input, long offset, long len, boolean flush) throws IOException - Parameters:
output
-input
-offset
- by bytelen
- by byteflush
-- Returns:
- Throws:
IOException
-
write
- Parameters:
output
-input
-- Returns:
- Throws:
IOException
-
write
- Parameters:
output
-input
-charset
-- Returns:
- Throws:
IOException
-
write
- Parameters:
output
-input
-offset
-len
-- Returns:
- Throws:
IOException
-
write
public static long write(File output, Reader input, long offset, long len, Charset charset) throws IOException - Parameters:
output
-input
-offset
- by charlen
- by charcharset
-- Returns:
- Throws:
IOException
-
write
- Parameters:
output
-input
-- Returns:
- Throws:
IOException
-
write
- Parameters:
output
-input
-offset
-len
-- Returns:
- Throws:
IOException
-
write
- Parameters:
output
-input
-flush
-- Returns:
- Throws:
IOException
-
write
public static long write(Writer output, Reader input, long offset, long len, boolean flush) throws IOException - Parameters:
output
-input
-offset
- by charlen
- by charflush
-- Returns:
- Throws:
IOException
-
write
- Parameters:
output
-input
-- Returns:
- Throws:
IOException
-
write
- Parameters:
output
-input
-offset
-len
-- Returns:
- Throws:
IOException
-
write
- Parameters:
output
-input
-- Returns:
- Throws:
IOException
-
write
- Parameters:
output
-input
-offset
-len
-- Returns:
- Throws:
IOException
-
write
- Parameters:
output
-input
-flush
-- Returns:
- Throws:
IOException
-
write
public static long write(OutputStream output, File input, long offset, long len, boolean flush) throws IOException - Parameters:
output
-input
-offset
- by bytelen
- by byteflush
-- Returns:
- Throws:
IOException
-
write
- Parameters:
output
-input
-- Returns:
- Throws:
IOException
-
write
- Parameters:
output
-input
-offset
-len
-- Returns:
- Throws:
IOException
-
write
- Parameters:
output
-input
-flush
-- Returns:
- Throws:
IOException
-
write
public static long write(Writer output, File input, long offset, long len, boolean flush) throws IOException - Parameters:
output
-input
-offset
- by charlen
- by charflush
-- Returns:
- Throws:
IOException
-
append
- Parameters:
output
-bytes
-- Throws:
IOException
-
append
- Parameters:
output
-bytes
-offset
-len
-- Throws:
IOException
-
append
- Parameters:
output
-chars
-- Throws:
IOException
-
append
- Parameters:
output
-chars
-charset
-- Throws:
IOException
-
append
- Parameters:
output
-chars
-offset
-len
-- Throws:
IOException
-
append
public static void append(File output, char[] chars, int offset, int len, Charset charset) throws IOException - Parameters:
output
-chars
-offset
-len
-charset
-- Throws:
IOException
-
append
- Parameters:
output
-str
-- Throws:
IOException
-
append
- Parameters:
output
-str
-charset
-- Throws:
IOException
-
append
- Parameters:
output
-input
-- Returns:
- Throws:
IOException
-
append
- Parameters:
output
-input
-offset
- by bytelen
- by byte- Returns:
- Throws:
IOException
-
append
- Parameters:
output
-input
-- Returns:
- Throws:
IOException
-
append
- Parameters:
output
-input
-charset
-- Returns:
- Throws:
IOException
-
append
- Parameters:
output
-input
-offset
-len
-- Returns:
- Throws:
IOException
-
append
public static long append(File output, Reader input, long offset, long len, Charset charset) throws IOException - Parameters:
output
-input
-offset
- by charlen
- by charcharset
-- Returns:
- Throws:
IOException
-
append
- Parameters:
output
-input
-- Returns:
- Throws:
IOException
-
append
- Parameters:
output
-input
-offset
-len
-- Returns:
- Throws:
IOException
-
appendLine
- Parameters:
output
-str
-- Throws:
IOException
-
appendLine
- Parameters:
output
-str
-charset
-- Throws:
IOException
-
skip
Return the count of skipped bytes.- Parameters:
input
-toSkip
-- Returns:
- Throws:
IOException
-
skip
Return the count of skipped chars.- Parameters:
input
-toSkip
-- Returns:
- Throws:
IOException
-
skipFully
- Parameters:
input
-toSkip
-- Throws:
IOException
- if the remaining length of the specifiedinput
is less than the specifiedtoSkip
-
skipFully
- Parameters:
input
-toSkip
-- Throws:
IOException
- if the remaining length of the specifiedinput
is less than the specifiedtoSkip
-
map
Note: copied from Google Guava under Apache License v2.- Parameters:
file
-- Returns:
- Throws:
IOException
-
map
Note: copied from Google Guava under Apache License v2. Fully maps a file in to memory as perFileChannel.map(java.nio.channels.FileChannel.MapMode, long, long)
using the requestedFileChannel.MapMode
.Files are mapped from offset 0 to its length.
This only works for files invalid input: '<'=
Integer.MAX_VALUE
bytes.- Parameters:
file
- the file to mapmode
- the mode to use when mappingfile
- Returns:
- a buffer reflecting
file
- Throws:
IOException
- Since:
- 2.0
- See Also:
-
map
public static MappedByteBuffer map(File file, FileChannel.MapMode mode, long offset, long len) throws IOException Note: copied from Google Guava under Apache License v2. Maps a file in to memory as perFileChannel.map(java.nio.channels.FileChannel.MapMode, long, long)
using the requestedFileChannel.MapMode
.Files are mapped from offset 0 to
size
.If the mode is
FileChannel.MapMode.READ_WRITE
and the file does not exist, it will be created with the requestedsize
. Thus this method is useful for creating memory mapped files which do not yet exist.This only works for files invalid input: '<'=
Integer.MAX_VALUE
bytes.- Parameters:
file
- the file to mapmode
- the mode to use when mappingfile
offset
-len
-- Returns:
- a buffer reflecting
file
- Throws:
IOException
- Since:
- 2.0
- See Also:
-
simplifyPath
Note: copied from Google Guava under Apache License v2. Returns the lexically cleaned form of the path name, usually (but not always) equivalent to the original. The following heuristics are used:- empty string becomes .
- . stays as .
- fold output ./
- fold output ../ when possible
- collapse multiple slashes
- delete trailing slashes (unless the path is just "/")
These heuristics do not always match the behavior of the filesystem. In particular, consider the path
a/../b
, whichsimplifyPath
will change tob
. Ifa
is a symlink tox
,a/../b
may refer to a sibling ofx
, rather than the sibling ofa
referred to byb
.- Parameters:
pathname
-- Returns:
- Since:
- 11.0
-
getFileExtension
Note: copied from Google Guava under Apache License v2. Returns the file extension for the given file name, or the empty string if the file has no extension. The result does not include the '.
'.- Parameters:
fullName
-- Returns:
- Since:
- 11.0
-
getNameWithoutExtension
Note: copied from Google Guava under Apache License v2. Returns the file name without its file extension or path. This is similar to thebasename
unix command. The result does not include the '.
'.- Parameters:
file
- The name of the file to trim the extension from. This can be either a fully qualified file name (including a path) or just a file name.- Returns:
- The file name without its path or extension.
- Since:
- 14.0
-
newBufferedReader
New buffered reader.- Parameters:
file
-- Returns:
- Throws:
UncheckedIOException
- the unchecked IO exception
-
newBufferedReader
public static BufferedReader newBufferedReader(File file, Charset charset) throws UncheckedIOException New buffered reader.- Parameters:
file
-charset
-- Returns:
- Throws:
UncheckedIOException
- the unchecked IO exception
-
newBufferedReader
New buffered reader.- Parameters:
path
-- Returns:
- Throws:
UncheckedIOException
- the unchecked IO exception
-
newBufferedReader
public static BufferedReader newBufferedReader(Path path, Charset charset) throws UncheckedIOException New buffered reader.- Parameters:
path
-charset
-- Returns:
- Throws:
UncheckedIOException
- the unchecked IO exception
-
newBufferedReader
New buffered reader.- Parameters:
is
-- Returns:
- Throws:
UncheckedIOException
- the unchecked IO exception
-
newBufferedReader
public static BufferedReader newBufferedReader(InputStream is, Charset charset) throws UncheckedIOException New buffered reader.- Parameters:
is
-charset
-- Returns:
- Throws:
UncheckedIOException
- the unchecked IO exception
-
newBufferedWriter
New buffered writer.- Parameters:
file
-- Returns:
- Throws:
UncheckedIOException
- the unchecked IO exception
-
newBufferedWriter
public static BufferedWriter newBufferedWriter(File file, Charset charset) throws UncheckedIOException New buffered writer.- Parameters:
file
-charset
-- Returns:
- Throws:
UncheckedIOException
- the unchecked IO exception
-
newBufferedWriter
New buffered writer.- Parameters:
os
-- Returns:
-
newBufferedWriter
New buffered writer.- Parameters:
os
-charset
-- Returns:
-
newLZ4BlockInputStream
New LZ 4 block input stream.- Parameters:
is
-- Returns:
-
newLZ4BlockOutputStream
New LZ 4 block output stream.- Parameters:
os
-- Returns:
-
newLZ4BlockOutputStream
Creates a new input stream with the specified buffer size.- Parameters:
os
-blockSize
-- Returns:
-
newSnappyInputStream
New snappy input stream.- Parameters:
is
-- Returns:
- Throws:
UncheckedIOException
- the unchecked IO exception
-
newSnappyOutputStream
New snappy output stream.- Parameters:
os
-- Returns:
-
newSnappyOutputStream
Creates a new input stream with the specified buffer size.- Parameters:
os
-bufferSize
-- Returns:
-
newGZIPInputStream
New GZIP input stream.- Parameters:
is
-- Returns:
- Throws:
UncheckedIOException
- the unchecked IO exception
-
newBrotliInputStream
public static org.brotli.dec.BrotliInputStream newBrotliInputStream(InputStream is) throws UncheckedIOException New GZIP input stream.- Parameters:
is
-- Returns:
- Throws:
UncheckedIOException
- the unchecked IO exception
-
newGZIPInputStream
public static GZIPInputStream newGZIPInputStream(InputStream is, int bufferSize) throws UncheckedIOException Creates a new input stream with the specified buffer size.- Parameters:
is
-bufferSize
-- Returns:
- Throws:
UncheckedIOException
- the unchecked IO exception
-
newGZIPOutputStream
New GZIP output stream.- Parameters:
os
-- Returns:
- Throws:
UncheckedIOException
- the unchecked IO exception
-
newGZIPOutputStream
public static GZIPOutputStream newGZIPOutputStream(OutputStream os, int bufferSize) throws UncheckedIOException Creates a new input stream with the specified buffer size.- Parameters:
os
-bufferSize
-- Returns:
- Throws:
UncheckedIOException
- the unchecked IO exception
-
close
- Parameters:
closeable
-
-
closeAll
- Parameters:
a
-
-
closeAll
- Parameters:
c
-
-
closeQuietly
- Parameters:
closeable
-
-
closeAllQuietly
Close all quietly.- Parameters:
a
-
-
closeAllQuietly
Close all quietly.- Parameters:
c
-
-
copyFileToDirectory
- Parameters:
srcFile
-destDir
-- Throws:
UncheckedIOException
- the unchecked IO exception
-
copyFileToDirectory
public static void copyFileToDirectory(File srcFile, File destDir, boolean preserveFileDate) throws UncheckedIOException - Parameters:
srcFile
-destDir
-preserveFileDate
-- Throws:
UncheckedIOException
- the unchecked IO exception
-
copyFileToDirectory
public static <E extends Exception> void copyFileToDirectory(File srcFile, File destDir, boolean preserveFileDate, Throwables.BiPredicate<? super File, ? super File, throws UncheckedIOException, EE> filter) Copy the specifiedscrFile
if it's a file or its sub files/directories if it's a directory to the targetdestDir
with the specifiedfilter
.- Type Parameters:
E
-- Parameters:
srcFile
-destDir
-preserveFileDate
-filter
-- Throws:
UncheckedIOException
- the unchecked IO exceptionE
- the e
-
copy
@SafeVarargs public static Path copy(Path source, Path target, CopyOption... options) throws UncheckedIOException - Parameters:
source
-target
-options
-- Returns:
- Throws:
UncheckedIOException
- the unchecked IO exception- See Also:
-
copy
@SafeVarargs public static long copy(InputStream in, Path target, CopyOption... options) throws UncheckedIOException - Parameters:
in
-target
-options
-- Returns:
- Throws:
UncheckedIOException
- the unchecked IO exception- See Also:
-
copy
- Parameters:
source
-output
-- Returns:
- Throws:
UncheckedIOException
- the unchecked IO exception- See Also:
-
copyURLToFile
Copies bytes from the URLsource
to a filedestination
. The directories up todestination
will be created if they don't already exist.destination
will be overwritten if it already exists.Warning: this method does not set a connection or read timeout and thus might block forever. Use
copyURLToFile(URL, File, int, int)
with reasonable timeouts to prevent this.- Parameters:
source
- theURL
to copy bytes from, must not benull
destination
- the non-directoryFile
to write bytes to (possibly overwriting), must not benull
- Throws:
UncheckedIOException
- if an IO error occurs during copying
-
copyURLToFile
public static void copyURLToFile(URL source, File destination, int connectionTimeout, int readTimeout) throws UncheckedIOException Copies bytes from the URLsource
to a filedestination
. The directories up todestination
will be created if they don't already exist.destination
will be overwritten if it already exists.- Parameters:
source
- theURL
to copy bytes from, must not benull
destination
- the non-directoryFile
to write bytes to (possibly overwriting), must not benull
connectionTimeout
- the number of milliseconds until this method will timeout if no connection could be established to thesource
readTimeout
- the number of milliseconds until this method will timeout if no data could be read from thesource
- Throws:
UncheckedIOException
- if an IO error occurs during copying
-
move
- Parameters:
srcFile
-destDir
-- Throws:
UncheckedIOException
- the unchecked IO exception
-
renameTo
- Parameters:
srcFile
-newFileName
-- Returns:
true
if and only if the renaming succeeded;false
otherwise
-
deleteIfExists
Delete the specified file (or directory).- Parameters:
file
-- Returns:
- true if the file is deleted successfully, otherwise false if the file is null or doesn't exist, or can't be deleted.
-
deleteAllIfExists
Delete the specified file and all its sub files/directories if it's a directory.- Parameters:
file
-- Returns:
- true if the file is deleted successfully, otherwise false if the file is null or doesn't exist, or can't be deleted.
-
deleteFiles
- Parameters:
dir
-- Returns:
false
if the file or some of its sub files if it's directory can't be deleted.
-
deleteFiles
public static <E extends Exception> boolean deleteFiles(File dir, Throwables.BiPredicate<? super File, ? super File, throws EE> filter) Delete the specifieddir
if it's a file or its sub files/directories if it's a directory with the specified filter.- Type Parameters:
E
-- Parameters:
dir
-filter
-- Returns:
false
if the file or some of its sub files if it's directory can't be deleted.- Throws:
E
- the e
-
cleanDirectory
Cleans a directory without deleting it.- Parameters:
directory
- directory to clean- Returns:
false
if some of its sub files can't be deleted.- See Also:
-
createIfNotExists
Creates the if not exists.- Parameters:
file
-- Returns:
false
if file exists or failed to create new file.- Throws:
UncheckedIOException
- the unchecked IO exception
-
mkdirIfNotExists
-
mkdirsIfNotExists
-
isFileNewer
Tests if the specifiedFile
is newer than the specifiedDate
.- Parameters:
file
- theFile
of which the modification date must be compareddate
- the date reference- Returns:
- true if the
File
exists and has been modified after the givenDate
. - Throws:
IllegalArgumentException
- if the file or date isnull
-
isFileNewer
Tests if the specifiedFile
is newer than the referenceFile
.- Parameters:
file
- theFile
of which the modification date must be comparedreference
- theFile
of which the modification date is used- Returns:
- true if the
File
exists and has been modified more recently than the referenceFile
- Throws:
IllegalArgumentException
- if the file or reference file isnull
or the reference file doesn't exist
-
isFileOlder
Tests if the specifiedFile
is older than the specifiedDate
.- Parameters:
file
- theFile
of which the modification date must be compareddate
- the date reference- Returns:
- true if the
File
exists and has been modified before the givenDate
- Throws:
IllegalArgumentException
- if the file or date isnull
-
isFileOlder
Tests if the specifiedFile
is older than the referenceFile
.- Parameters:
file
- theFile
of which the modification date must be comparedreference
- theFile
of which the modification date is used- Returns:
- true if the
File
exists and has been modified before the referenceFile
- Throws:
IllegalArgumentException
- if the file or reference file isnull
or the reference file doesn't exist
-
isSymbolicLink
Determines whether the specified file is a Symbolic Link rather than an actual file.Will not return true if there is a Symbolic Link anywhere in the path, only if the specific file is.
When using jdk1.7, this method delegates to
boolean java.nio.file.Files.isSymbolicLink(Path path)
Note: the current implementation always returns
false
if running on jkd1.6 and the system is detected as Windows usinginvalid @link
FilenameUtil#isSystemWindows()
For code that runs on Java 1.7 or later, use the following method instead:
boolean java.nio.file.Files.isSymbolicLink(Path path)
- Parameters:
file
- the file to check- Returns:
- true if the file is a Symbolic Link
- Since:
- 2.0
-
sizeOf
Returns the size of the specified file or directory. If the providedFile
is a regular file, then the file's length is returned. If the argument is a directory, then the size of the directory is calculated recursively. If a directory or subdirectory is security restricted, its size will not be included.Note that overflow is not detected, and the return value may be negative if overflow occurs. See
invalid @link
#sizeOfAsBigInteger(File)
- Parameters:
file
- the regular file or directory to return the size of (must not benull
).- Returns:
- the length of the file, or recursive size of the directory, provided (in bytes).
- Throws:
IllegalArgumentException
- if the file isnull
or the file does not exist.- Since:
- 2.0
-
sizeOfDirectory
Counts the size of a directory recursively (sum of the length of all files).Note that overflow is not detected, and the return value may be negative if overflow occurs. See
invalid @link
#sizeOfDirectoryAsBigInteger(File)
- Parameters:
directory
- directory to inspect, must not benull
- Returns:
- size of directory in bytes, 0 if directory is security restricted, a negative number when the real total is greater than
Long.MAX_VALUE
. - Throws:
IllegalArgumentException
- if the directory isnull
or it's not existed directory.
-
zip
- Parameters:
sourceFile
-targetFile
-- Throws:
UncheckedIOException
- the unchecked IO exception
-
zip
- Parameters:
sourceFiles
-targetFile
-- Throws:
UncheckedIOException
- the unchecked IO exception
-
unzip
- Parameters:
srcZipFile
-targetDir
-
-
split
- Parameters:
file
-countOfParts
-- Throws:
UncheckedIOException
- the unchecked IO exception
-
split
- Parameters:
file
-countOfParts
-destDir
-- Throws:
UncheckedIOException
- the unchecked IO exception
-
splitBySize
Split by size.- Parameters:
file
-sizeOfPart
-- Throws:
UncheckedIOException
- the unchecked IO exception
-
splitBySize
public static void splitBySize(File file, long sizeOfPart, File destDir) throws UncheckedIOException Mostly it's designed for (zipped/unzipped/log) text files.- Parameters:
file
-sizeOfPart
-destDir
-- Throws:
UncheckedIOException
- the unchecked IO exception
-
merge
- Parameters:
sourceFiles
-destFile
-- Returns:
- Throws:
UncheckedIOException
- the unchecked IO exception
-
merge
Merge the specified source files into the destination file.- Parameters:
sourceFiles
-destFile
-- Returns:
- Throws:
UncheckedIOException
- the unchecked IO exception
-
list
- Parameters:
parentPath
-- Returns:
-
list
- Parameters:
parentPath
-recursively
-excludeDirectory
-- Returns:
-
list
public static <E extends Exception> List<String> list(File parentPath, boolean recursively, Throwables.BiPredicate<? super File, ? super File, throws EE> filter) - Type Parameters:
E
-- Parameters:
parentPath
-recursively
-filter
-- Returns:
- Throws:
E
- the e
-
listFiles
- Parameters:
parentPath
-- Returns:
-
listFiles
- Parameters:
parentPath
-recursively
-excludeDirectory
-- Returns:
-
listFiles
public static <E extends Exception> List<File> listFiles(File parentPath, boolean recursively, Throwables.BiPredicate<? super File, ? super File, throws EE> filter) - Type Parameters:
E
-- Parameters:
parentPath
-recursively
-filter
-- Returns:
- Throws:
E
- the e
-
listDirectories
- Parameters:
parentPath
-- Returns:
-
listDirectories
- Parameters:
parentPath
-recursively
-- Returns:
-
toFile
Convert from aURL
to aFile
.From version 1.1 this method will decode the URL. Syntax such as
file:///my%20docs/file.txt
will be correctly decoded to/my docs/file.txt
. Starting with version 1.5, this method uses UTF-8 to decode percent-encoded octets to characters. Additionally, malformed percent-encoded octets are handled leniently by passing them through literally.- Parameters:
url
- the file URL to convert,null
returnsnull
- Returns:
- Throws:
NullPointerException
- if the parameter is null
-
toFiles
Converts each of an array ofURL
to aFile
.Returns an array of the same size as the input. If the input is
null
, an empty array is returned. If the input containsnull
, the output array containsnull
at the same index.This method will decode the URL. Syntax such as
file:///my%20docs/file.txt
will be correctly decoded to/my docs/file.txt
.- Parameters:
urls
- the file URLs to convert,null
returns empty array- Returns:
- a non-
null
array of Files matching the input, with anull
item if there was anull
at that index in the input array - Throws:
UncheckedIOException
- the unchecked IO exceptionIllegalArgumentException
- if any file is incorrectly encoded- Since:
- 1.1
-
toFiles
- Parameters:
urls
-- Returns:
- Throws:
UncheckedIOException
- the unchecked IO exception
-
toURL
- Parameters:
file
-- Returns:
- Throws:
UncheckedIOException
- the unchecked IO exception
-
toURLs
To UR ls.- Parameters:
files
-- Returns:
- Throws:
UncheckedIOException
- the unchecked IO exception
-
toURLs
To UR ls.- Parameters:
files
-- Returns:
- Throws:
UncheckedIOException
- the unchecked IO exception
-
touch
Update the last modified time of the file to system current time if the specified file exists.- Parameters:
file
- the File to touch- Returns:
- true if the file exists and last modified time is updated successfully.
-
parse
public static <E extends Exception> void parse(File file, Throwables.Consumer<String, E> lineParser) throws UncheckedIOException, E- Type Parameters:
E
-- Parameters:
file
-lineParser
-- Throws:
UncheckedIOException
- the unchecked IO exceptionE
- the e
-
parse
public static <E extends Exception,E2 extends Exception> void parse(File file, Throwables.Consumer<String, E> lineParser, Throwables.Runnable<E2> onComplete) throws UncheckedIOException, E, E2- Type Parameters:
E
-E2
-- Parameters:
file
-lineParser
-onComplete
-- Throws:
UncheckedIOException
- the unchecked IO exceptionE
- the eE2
- the e2
-
parse
public static <E extends Exception> void parse(File file, long lineOffset, long count, Throwables.Consumer<String, E> lineParser) throws UncheckedIOException, E- Type Parameters:
E
-- Parameters:
file
-lineOffset
-count
-lineParser
-- Throws:
UncheckedIOException
- the unchecked IO exceptionE
- the e
-
parse
public static <E extends Exception,E2 extends Exception> void parse(File file, long lineOffset, long count, Throwables.Consumer<String, E> lineParser, Throwables.Runnable<E2> onComplete) throws UncheckedIOException, E, E2- Type Parameters:
E
-E2
-- Parameters:
file
-lineOffset
-count
-lineParser
-onComplete
-- Throws:
UncheckedIOException
- the unchecked IO exceptionE
- the eE2
- the e2
-
parse
public static <E extends Exception> void parse(File file, long lineOffset, long count, int processThreadNum, int queueSize, Throwables.Consumer<String, E> lineParser) throws UncheckedIOException, E- Type Parameters:
E
-- Parameters:
file
-lineOffset
-count
-processThreadNum
-queueSize
-lineParser
-- Throws:
UncheckedIOException
- the unchecked IO exceptionE
- the e
-
parse
public static <E extends Exception,E2 extends Exception> void parse(File file, long lineOffset, long count, int processThreadNum, int queueSize, Throwables.Consumer<String, E> lineParser, Throwables.Runnable<E2> onComplete) throws UncheckedIOException, E, E2Parse the specified files/directory line by line.- Type Parameters:
E
-E2
-- Parameters:
file
- parse all the sub files recursively if the element is a directory.lineOffset
-count
-processThreadNum
- new threads started to parse/process the lines/recordsqueueSize
-lineParser
-onComplete
-- Throws:
UncheckedIOException
- the unchecked IO exceptionE
- the eE2
- the e2
-
parse
public static <E extends Exception> void parse(List<File> files, Throwables.Consumer<String, E> lineParser) throws UncheckedIOException, E- Type Parameters:
E
-- Parameters:
files
-lineParser
-- Throws:
UncheckedIOException
- the unchecked IO exceptionE
- the e
-
parse
public static <E extends Exception,E2 extends Exception> void parse(List<File> files, Throwables.Consumer<String, E> lineParser, Throwables.Runnable<E2> onComplete) throws UncheckedIOException, E, E2- Type Parameters:
E
-E2
-- Parameters:
files
-lineParser
-onComplete
-- Throws:
UncheckedIOException
- the unchecked IO exceptionE
- the eE2
- the e2
-
parse
public static <E extends Exception> void parse(List<File> files, long lineOffset, long count, Throwables.Consumer<String, E> lineParser) throws UncheckedIOException, E- Type Parameters:
E
-- Parameters:
files
-lineOffset
-count
-lineParser
-- Throws:
UncheckedIOException
- the unchecked IO exceptionE
- the e
-
parse
public static <E extends Exception,E2 extends Exception> void parse(List<File> files, long lineOffset, long count, Throwables.Consumer<String, E> lineParser, Throwables.Runnable<E2> onComplete) throws UncheckedIOException, E, E2- Type Parameters:
E
-E2
-- Parameters:
files
-lineOffset
-count
-lineParser
-onComplete
-- Throws:
UncheckedIOException
- the unchecked IO exceptionE
- the eE2
- the e2
-
parse
public static <E extends Exception> void parse(List<File> files, long lineOffset, long count, int processThreadNum, int queueSize, Throwables.Consumer<String, E> lineParser) throws UncheckedIOException, E- Type Parameters:
E
-- Parameters:
files
-lineOffset
-count
-processThreadNum
-queueSize
-lineParser
-- Throws:
UncheckedIOException
- the unchecked IO exceptionE
- the e
-
parse
public static <E extends Exception,E2 extends Exception> void parse(List<File> files, long lineOffset, long count, int processThreadNum, int queueSize, Throwables.Consumer<String, E> lineParser, Throwables.Runnable<E2> onComplete) throws UncheckedIOException, E, E2Parse the specified files/directory line by line.- Type Parameters:
E
-E2
-- Parameters:
files
- parse all the sub files recursively if the element is a directory.lineOffset
-count
-processThreadNum
- thread number used to parse/process the lines/recordsqueueSize
- size of queue to save the processing records/lines loaded from source data. Default size is 1024.lineParser
-onComplete
-- Throws:
UncheckedIOException
- the unchecked IO exceptionE
- the eE2
- the e2
-
parse
public static <E extends Exception> void parse(File file, int readThreadNum, int processThreadNum, int queueSize, Throwables.Consumer<String, E> lineParser) throws UncheckedIOException, E- Type Parameters:
E
-- Parameters:
file
-readThreadNum
-processThreadNum
-queueSize
-lineParser
-- Throws:
UncheckedIOException
- the unchecked IO exceptionE
- the e
-
parse
public static <E extends Exception,E2 extends Exception> void parse(File file, int readThreadNum, int processThreadNum, int queueSize, Throwables.Consumer<String, E> lineParser, Throwables.Runnable<E2> onComplete) throws UncheckedIOException, E, E2- Type Parameters:
E
-E2
-- Parameters:
file
-readThreadNum
-processThreadNum
-queueSize
-lineParser
-onComplete
-- Throws:
UncheckedIOException
- the unchecked IO exceptionE
- the eE2
- the e2
-
parse
public static <E extends Exception> void parse(File file, long lineOffset, long count, int readThreadNum, int processThreadNum, int queueSize, Throwables.Consumer<String, E> lineParser) throws UncheckedIOException, E- Type Parameters:
E
-- Parameters:
file
-lineOffset
-count
-readThreadNum
-processThreadNum
-queueSize
-lineParser
-- Throws:
UncheckedIOException
- the unchecked IO exceptionE
- the e
-
parse
public static <E extends Exception,E2 extends Exception> void parse(File file, long lineOffset, long count, int readThreadNum, int processThreadNum, int queueSize, Throwables.Consumer<String, E> lineParser, Throwables.Runnable<E2> onComplete) throws UncheckedIOException, E, E2Parse the specified files/directory line by line.- Type Parameters:
E
-E2
-- Parameters:
file
- parse all the sub files recursively if the element is a directory.lineOffset
-count
-readThreadNum
- new threads started to parse/process the lines/recordsprocessThreadNum
- new threads started to parse/process the lines/recordsqueueSize
- size of queue to save the processing records/lines loaded from source data. Default size is 1024.lineParser
-onComplete
-- Throws:
UncheckedIOException
- the unchecked IO exceptionE
- the eE2
- the e2
-
parse
public static <E extends Exception> void parse(List<File> files, int readThreadNum, int processThreadNum, int queueSize, Throwables.Consumer<String, E> lineParser) throws UncheckedIOException, E- Type Parameters:
E
-- Parameters:
files
-readThreadNum
-processThreadNum
-queueSize
-lineParser
-- Throws:
UncheckedIOException
- the unchecked IO exceptionE
- the e
-
parse
public static <E extends Exception,E2 extends Exception> void parse(List<File> files, int readThreadNum, int processThreadNum, int queueSize, Throwables.Consumer<String, E> lineParser, Throwables.Runnable<E2> onComplete) throws UncheckedIOException, E, E2- Type Parameters:
E
-E2
-- Parameters:
files
-readThreadNum
-processThreadNum
-queueSize
-lineParser
-onComplete
-- Throws:
UncheckedIOException
- the unchecked IO exceptionE
- the eE2
- the e2
-
parse
public static <E extends Exception> void parse(List<File> files, long lineOffset, long count, int readThreadNum, int processThreadNum, int queueSize, Throwables.Consumer<String, E> lineParser) throws UncheckedIOException, E- Type Parameters:
E
-- Parameters:
files
-lineOffset
-count
-readThreadNum
-processThreadNum
-queueSize
-lineParser
-- Throws:
UncheckedIOException
- the unchecked IO exceptionE
- the e
-
parse
public static <E extends Exception,E2 extends Exception> void parse(List<File> files, long lineOffset, long count, int readThreadNum, int processThreadNum, int queueSize, Throwables.Consumer<String, E> lineParser, Throwables.Runnable<E2> onComplete) throws UncheckedIOException, E, E2Parse the specified files/directory line by line.- Type Parameters:
E
-E2
-- Parameters:
files
- parse all the sub files recursively if the element is a directory.lineOffset
-count
-readThreadNum
- new threads started to parse/process the lines/recordsprocessThreadNum
- new threads started to parse/process the lines/recordsqueueSize
- size of queue to save the processing records/lines loaded from source data. Default size is 1024.lineParser
-onComplete
-- Throws:
UncheckedIOException
- the unchecked IO exceptionE
- the eE2
- the e2
-
parse
public static <E extends Exception> void parse(InputStream is, Throwables.Consumer<String, E> lineParser) throws UncheckedIOException, E- Type Parameters:
E
-- Parameters:
is
-lineParser
-- Throws:
UncheckedIOException
- the unchecked IO exceptionE
- the e
-
parse
public static <E extends Exception,E2 extends Exception> void parse(InputStream is, Throwables.Consumer<String, E> lineParser, Throwables.Runnable<E2> onComplete) throws UncheckedIOException, E, E2- Type Parameters:
E
-E2
-- Parameters:
is
-lineParser
-onComplete
-- Throws:
UncheckedIOException
- the unchecked IO exceptionE
- the eE2
- the e2
-
parse
public static <E extends Exception> void parse(InputStream is, long lineOffset, long count, Throwables.Consumer<String, E> lineParser) throws UncheckedIOException, E- Type Parameters:
E
-- Parameters:
is
-lineOffset
-count
-lineParser
-- Throws:
UncheckedIOException
- the unchecked IO exceptionE
- the e
-
parse
public static <E extends Exception,E2 extends Exception> void parse(InputStream is, long lineOffset, long count, Throwables.Consumer<String, E> lineParser, Throwables.Runnable<E2> onComplete) throws UncheckedIOException, E, E2- Type Parameters:
E
-E2
-- Parameters:
is
-lineOffset
-count
-lineParser
-onComplete
-- Throws:
UncheckedIOException
- the unchecked IO exceptionE
- the eE2
- the e2
-
parse
public static <E extends Exception> void parse(InputStream is, long lineOffset, long count, int processThreadNum, int queueSize, Throwables.Consumer<String, E> lineParser) throws UncheckedIOException, E- Type Parameters:
E
-- Parameters:
is
-lineOffset
-count
-processThreadNum
-queueSize
-lineParser
-- Throws:
UncheckedIOException
- the unchecked IO exceptionE
- the e
-
parse
public static <E extends Exception,E2 extends Exception> void parse(InputStream is, long lineOffset, long count, int processThreadNum, int queueSize, Throwables.Consumer<String, E> lineParser, Throwables.Runnable<E2> onComplete) throws UncheckedIOException, E, E2Parse the specified Reader line by line.- Type Parameters:
E
-E2
-- Parameters:
is
-lineOffset
-count
-processThreadNum
- new threads started to parse/process the lines/recordsqueueSize
- size of queue to save the processing records/lines loaded from source data. Default size is 1024.lineParser
-onComplete
-- Throws:
UncheckedIOException
- the unchecked IO exceptionE
- the eE2
- the e2
-
parse
public static <E extends Exception> void parse(Reader reader, Throwables.Consumer<String, E> lineParser) throws UncheckedIOException, E- Type Parameters:
E
-- Parameters:
reader
-lineParser
-- Throws:
UncheckedIOException
- the unchecked IO exceptionE
- the e
-
parse
public static <E extends Exception,E2 extends Exception> void parse(Reader reader, Throwables.Consumer<String, E> lineParser, Throwables.Runnable<E2> onComplete) throws UncheckedIOException, E, E2- Type Parameters:
E
-E2
-- Parameters:
reader
-lineParser
-onComplete
-- Throws:
UncheckedIOException
- the unchecked IO exceptionE
- the eE2
- the e2
-
parse
public static <E extends Exception> void parse(Reader reader, long lineOffset, long count, Throwables.Consumer<String, E> lineParser) throws UncheckedIOException, E- Type Parameters:
E
-- Parameters:
reader
-lineOffset
-count
-lineParser
-- Throws:
UncheckedIOException
- the unchecked IO exceptionE
- the e
-
parse
public static <E extends Exception,E2 extends Exception> void parse(Reader reader, long lineOffset, long count, Throwables.Consumer<String, E> lineParser, Throwables.Runnable<E2> onComplete) throws UncheckedIOException, E, E2- Type Parameters:
E
-E2
-- Parameters:
reader
-lineOffset
-count
-lineParser
-onComplete
-- Throws:
UncheckedIOException
- the unchecked IO exceptionE
- the eE2
- the e2
-
parse
public static <E extends Exception> void parse(Reader reader, long lineOffset, long count, int processThreadNum, int queueSize, Throwables.Consumer<String, E> lineParser) throws UncheckedIOException, E- Type Parameters:
E
-- Parameters:
reader
-lineOffset
-count
-processThreadNum
-queueSize
-lineParser
-- Throws:
UncheckedIOException
- the unchecked IO exceptionE
- the e
-
parse
public static <E extends Exception,E2 extends Exception> void parse(Reader reader, long lineOffset, long count, int processThreadNum, int queueSize, Throwables.Consumer<String, E> lineParser, Throwables.Runnable<E2> onComplete) throws UncheckedIOException, E, E2Parse the specified Reader line by line.- Type Parameters:
E
-E2
-- Parameters:
reader
-lineOffset
-count
-processThreadNum
- new threads started to parse/process the lines/recordsqueueSize
- size of queue to save the processing records/lines loaded from source data. Default size is 1024.lineParser
-onComplete
-- Throws:
UncheckedIOException
- the unchecked IO exceptionE
- the eE2
- the e2
-