Class IOUtil

java.lang.Object
com.landawn.abacus.util.IOUtil

public final class IOUtil extends Object

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 Details

    • 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

      public static final String OS_NAME
    • OS_VERSION

      public static final String OS_VERSION
    • OS_ARCH

      public static final String 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

      public static final String JAVA_HOME
    • JAVA_VERSION

      public static final JavaVersion JAVA_VERSION
    • JAVA_VENDOR

      public static final String JAVA_VENDOR
    • JAVA_CLASS_PATH

      public static final String JAVA_CLASS_PATH
    • JAVA_CLASS_VERSION

      public static final String JAVA_CLASS_VERSION
    • JAVA_RUNTIME_NAME

      public static final String JAVA_RUNTIME_NAME
    • JAVA_RUNTIME_VERSION

      public static final String JAVA_RUNTIME_VERSION
    • JAVA_SPECIFICATION_NAME

      public static final String JAVA_SPECIFICATION_NAME
    • JAVA_SPECIFICATION_VENDOR

      public static final String JAVA_SPECIFICATION_VENDOR
    • JAVA_SPECIFICATION_VERSION

      public static final String JAVA_SPECIFICATION_VERSION
    • JAVA_VM_INFO

      public static final String JAVA_VM_INFO
    • JAVA_VM_NAME

      public static final String JAVA_VM_NAME
    • JAVA_VM_SPECIFICATION_NAME

      public static final String JAVA_VM_SPECIFICATION_NAME
    • JAVA_VM_SPECIFICATION_VENDOR

      public static final String JAVA_VM_SPECIFICATION_VENDOR
    • JAVA_VM_SPECIFICATION_VERSION

      public static final String JAVA_VM_SPECIFICATION_VERSION
    • JAVA_VM_VENDOR

      public static final String JAVA_VM_VENDOR
    • JAVA_VM_VERSION

      public static final String JAVA_VM_VERSION
    • JAVA_IO_TMPDIR

      public static final String JAVA_IO_TMPDIR
    • USER_DIR

      public static final String USER_DIR
    • USER_HOME

      public static final String USER_HOME
    • USER_NAME

      public static final String USER_NAME
    • USER_TIMEZONE

      public static final String USER_TIMEZONE
    • USER_LANGUAGE

      public static final String USER_LANGUAGE
    • USER_COUNTRY

      public static final String USER_COUNTRY
    • CURRENT_PATH

      public static final String CURRENT_PATH
      current path retrieved by new File("./").getAbsolutePath()
    • PATH_SEPARATOR

      public static final String PATH_SEPARATOR
    • FILE_SEPARATOR

      public static final String FILE_SEPARATOR
    • LINE_SEPARATOR

      public static final String LINE_SEPARATOR
    • EOF

      public static final int EOF
      See Also:
  • Method Details

    • getHostName

      public static String getHostName()
    • freeDiskSpaceKb

      public static long freeDiskSpaceKb() throws UncheckedIOException
      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 space
      IllegalStateException - if an error occurred in initialisation
    • freeDiskSpaceKb

      public static long freeDiskSpaceKb(long timeout) throws UncheckedIOException
      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 space
      IllegalStateException - if an error occurred in initialisation
    • freeDiskSpaceKb

      public static long freeDiskSpaceKb(String path) throws UncheckedIOException
      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 space
      IllegalArgumentException - if the path is invalid
      IllegalStateException - if an error occurred in initialisation
    • freeDiskSpaceKb

      public static long freeDiskSpaceKb(String path, long timeout) throws UncheckedIOException
      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
      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 space
      IllegalArgumentException - if the path is invalid
      IllegalStateException - if an error occurred in initialisation
    • chars2Bytes

      public static byte[] chars2Bytes(char[] chars)
      Chars 2 bytes.
      Parameters:
      chars -
      Returns:
    • chars2Bytes

      public static byte[] chars2Bytes(char[] chars, Charset charset)
      Chars 2 bytes.
      Parameters:
      chars -
      charset -
      Returns:
    • chars2Bytes

      public static byte[] chars2Bytes(char[] chars, int offset, int len, Charset charset)
      Chars 2 bytes.
      Parameters:
      chars -
      offset -
      len -
      charset -
      Returns:
    • bytes2Chars

      public static char[] bytes2Chars(byte[] bytes)
      Bytes 2 chars.
      Parameters:
      bytes -
      Returns:
    • bytes2Chars

      public static char[] bytes2Chars(byte[] bytes, Charset charset)
      Bytes 2 chars.
      Parameters:
      bytes -
      charset -
      Returns:
    • bytes2Chars

      public static char[] bytes2Chars(byte[] bytes, int offset, int len, Charset charset)
      Bytes 2 chars.
      Parameters:
      bytes -
      offset -
      len -
      charset -
      Returns:
    • string2InputStream

      public static InputStream string2InputStream(String str)
      String 2 input stream.
      Parameters:
      str -
      Returns:
    • string2InputStream

      public static InputStream string2InputStream(String str, Charset charset)
      String 2 input stream.
      Parameters:
      str -
      charset -
      Returns:
    • string2Reader

      public static Reader string2Reader(String str)
      String 2 reader.
      Parameters:
      str -
      Returns:
    • stringBuilder2Writer

      public static Writer stringBuilder2Writer(StringBuilder sb)
      String builder 2 writer.
      Parameters:
      sb -
      Returns:
    • readAllBytes

      public static byte[] readAllBytes(File file) throws UncheckedIOException
      Note: It should not be used to read File/InputStream with size closed to Integer.MAX_VALUE.
      Parameters:
      file -
      Returns:
      Throws:
      UncheckedIOException - the unchecked IO exception
    • readAllBytes

      public static byte[] readAllBytes(InputStream is) throws UncheckedIOException
      Note: It should not be used to read File/InputStream with size closed to Integer.MAX_VALUE.
      Parameters:
      is -
      Returns:
      Throws:
      UncheckedIOException - the unchecked IO exception
    • readBytes

      public static byte[] readBytes(File file) throws IOException
      Parameters:
      file -
      Returns:
      Throws:
      IOException - the unchecked IO exception
      See Also:
    • readBytes

      public static byte[] readBytes(File file, long offset, int maxLen) throws IOException
      Parameters:
      file -
      offset -
      maxLen -
      Returns:
      Throws:
      IOException
    • readBytes

      public static byte[] readBytes(InputStream is) throws IOException
      Parameters:
      is -
      Returns:
      Throws:
      IOException
      See Also:
    • readBytes

      public static byte[] readBytes(InputStream is, long offset, int maxLen) throws IOException
      Parameters:
      is -
      offset -
      maxLen -
      Returns:
      Throws:
      IOException
    • readAllChars

      public static char[] readAllChars(File file) throws UncheckedIOException
      Note: It should not be used to read File/InputStream/Reader with size closed to Integer.MAX_VALUE.
      Parameters:
      file -
      Returns:
      Throws:
      UncheckedIOException - the unchecked IO exception
    • readAllChars

      public static char[] readAllChars(File file, Charset encoding) throws UncheckedIOException
      Note: It should not be used to read File/InputStream/Reader with size closed to Integer.MAX_VALUE.
      Parameters:
      file -
      encoding -
      Returns:
      Throws:
      UncheckedIOException - the unchecked IO exception
    • readAllChars

      public static char[] readAllChars(InputStream is) throws UncheckedIOException
      Note: It should not be used to read File/InputStream/Reader with size closed to Integer.MAX_VALUE.
      Parameters:
      is -
      Returns:
      Throws:
      UncheckedIOException - the unchecked IO exception
    • readAllChars

      public static char[] readAllChars(InputStream is, Charset encoding) throws UncheckedIOException
      Note: It should not be used to read File/InputStream/Reader with size closed to Integer.MAX_VALUE.
      Parameters:
      is -
      encoding -
      Returns:
      Throws:
      UncheckedIOException - the unchecked IO exception
    • readAllChars

      public static char[] readAllChars(Reader reader) throws UncheckedIOException
      Note: It should not be used to read File/InputStream/Reader with size closed to Integer.MAX_VALUE.
      Parameters:
      reader -
      Returns:
      Throws:
      UncheckedIOException - the unchecked IO exception
    • readChars

      public static char[] readChars(File file) throws IOException
      Parameters:
      file -
      Returns:
      Throws:
      IOException
      See Also:
    • readChars

      public static char[] readChars(File file, Charset encoding) throws IOException
      Parameters:
      file -
      encoding -
      Returns:
      Throws:
      IOException
      See Also:
    • readChars

      public static char[] readChars(File file, long offset, int maxLen) throws IOException
      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

      public static char[] readChars(InputStream is) throws IOException
      Parameters:
      is -
      Returns:
      Throws:
      IOException
      See Also:
    • readChars

      public static char[] readChars(InputStream is, Charset encoding) throws IOException
      Parameters:
      is -
      encoding -
      Returns:
      Throws:
      IOException
      See Also:
    • readChars

      public static char[] readChars(InputStream is, long offset, int maxLen) throws IOException
      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

      public static char[] readChars(Reader reader) throws IOException
      Parameters:
      reader -
      Returns:
      Throws:
      IOException
      See Also:
    • readChars

      public static char[] readChars(Reader reader, long offset, int maxLen) throws IOException
      Parameters:
      reader -
      offset -
      maxLen -
      Returns:
      Throws:
      IOException
    • readAllToString

      public static String readAllToString(File file) throws UncheckedIOException
      Read all content into one String.
      Note: It should not be used to read File/InputStream/Reader with size closed to Integer.MAX_VALUE.
      Parameters:
      file -
      Returns:
      Throws:
      UncheckedIOException - the unchecked IO exception
    • readAllToString

      public static String readAllToString(File file, Charset encoding) throws UncheckedIOException
      Read all content into one String.
      Note: It should not be used to read File/InputStream/Reader with size closed to Integer.MAX_VALUE.
      Parameters:
      file -
      encoding -
      Returns:
      Throws:
      UncheckedIOException - the unchecked IO exception
    • readAllToString

      public static String readAllToString(InputStream is) throws UncheckedIOException
      Read all content into one String.
      Note: It should not be used to read File/InputStream/Reader with size closed to Integer.MAX_VALUE.
      Parameters:
      is -
      Returns:
      Throws:
      UncheckedIOException - the unchecked IO exception
    • readAllToString

      public static String readAllToString(InputStream is, Charset encoding) throws UncheckedIOException
      Read all content into one String.
      Note: It should not be used to read File/InputStream/Reader with size closed to Integer.MAX_VALUE.
      Parameters:
      is -
      encoding -
      Returns:
      Throws:
      UncheckedIOException - the unchecked IO exception
    • readAllToString

      public static String readAllToString(Reader reader) throws UncheckedIOException
      Read all content into one String.
      Note: It should not be used to read File/InputStream/Reader with size closed to Integer.MAX_VALUE.
      Parameters:
      reader -
      Returns:
      Throws:
      UncheckedIOException - the unchecked IO exception
    • readToString

      public static String readToString(File file, long offset, int maxLen) throws UncheckedIOException
      Parameters:
      file -
      offset -
      maxLen -
      Returns:
      Throws:
      UncheckedIOException - the unchecked IO exception
    • readToString

      public static String readToString(File file, long offset, int maxLen, Charset encoding) throws UncheckedIOException
      Parameters:
      file -
      offset -
      maxLen -
      encoding -
      Returns:
      Throws:
      UncheckedIOException - the unchecked IO exception
    • readToString

      public static String readToString(InputStream is, long offset, int maxLen) throws UncheckedIOException
      Parameters:
      is -
      offset -
      maxLen -
      Returns:
      Throws:
      UncheckedIOException - the unchecked IO exception
    • readToString

      public static String readToString(InputStream is, long offset, int maxLen, Charset encoding) throws UncheckedIOException
      Parameters:
      is -
      offset -
      maxLen -
      encoding -
      Returns:
      Throws:
      UncheckedIOException - the unchecked IO exception
    • readToString

      public static String readToString(Reader reader, long offset, int maxLen) throws UncheckedIOException
      Parameters:
      reader -
      offset -
      maxLen -
      Returns:
      Throws:
      UncheckedIOException - the unchecked IO exception
    • readAllLines

      public static List<String> readAllLines(File file) throws UncheckedIOException

      Note: It should not be used to read File/InputStream/Reader with size closed to Integer.MAX_VALUE.
      Parameters:
      file -
      Returns:
      Throws:
      UncheckedIOException - the unchecked IO exception
    • readAllLines

      public static List<String> readAllLines(File file, Charset encoding) throws UncheckedIOException

      Note: It should not be used to read File/InputStream/Reader with size closed to Integer.MAX_VALUE.
      Parameters:
      file -
      encoding -
      Returns:
      Throws:
      UncheckedIOException - the unchecked IO exception
    • readAllLines

      public static List<String> readAllLines(InputStream is) throws UncheckedIOException

      Note: It should not be used to read File/InputStream/Reader with size closed to Integer.MAX_VALUE.
      Parameters:
      is -
      Returns:
      Throws:
      UncheckedIOException - the unchecked IO exception
    • readAllLines

      public static List<String> readAllLines(InputStream is, Charset encoding) throws UncheckedIOException

      Note: It should not be used to read File/InputStream/Reader with size closed to Integer.MAX_VALUE.
      Parameters:
      is -
      encoding -
      Returns:
      Throws:
      UncheckedIOException - the unchecked IO exception
    • readAllLines

      public static List<String> readAllLines(Reader reader) throws UncheckedIOException

      Note: It should not be used to read File/InputStream/Reader with size closed to Integer.MAX_VALUE.
      Parameters:
      reader -
      Returns:
      Throws:
      UncheckedIOException - the unchecked IO exception
    • readFirstLine

      public static String readFirstLine(File file) throws IOException
      Parameters:
      file -
      Returns:
      null if the specified file/InputStream/Reader is empty.
      Throws:
      IOException
    • readFirstLine

      public static String readFirstLine(File file, Charset encoding) throws IOException
      Parameters:
      file -
      encoding -
      Returns:
      null if the specified file/InputStream/Reader is empty.
      Throws:
      IOException
    • readFirstLine

      public static String readFirstLine(InputStream is) throws IOException
      Parameters:
      is -
      Returns:
      null if the specified file/InputStream/Reader is empty.
      Throws:
      IOException
    • readFirstLine

      public static String readFirstLine(InputStream is, Charset encoding) throws IOException
      Parameters:
      is -
      encoding -
      Returns:
      null if the specified file/InputStream/Reader is empty.
      Throws:
      IOException
    • readFirstLine

      public static String readFirstLine(Reader reader) throws IOException
      Parameters:
      reader -
      Returns:
      null if the specified file/InputStream/Reader is empty.
      Throws:
      IOException
    • readLastLine

      public static String readLastLine(File file) throws IOException
      Parameters:
      file -
      Returns:
      Throws:
      IOException
    • readLastLine

      public static String readLastLine(File file, Charset encoding) throws IOException
      Parameters:
      file -
      encoding -
      Returns:
      null if the specified file/InputStream/Reader is empty.
      Throws:
      IOException
    • readLastLine

      public static String readLastLine(InputStream is) throws IOException
      Parameters:
      is -
      Returns:
      null if the specified file/InputStream/Reader is empty.
      Throws:
      IOException
    • readLastLine

      public static String readLastLine(InputStream is, Charset encoding) throws IOException
      Parameters:
      is -
      encoding -
      Returns:
      null if the specified file/InputStream/Reader is empty.
      Throws:
      IOException
    • readLastLine

      public static String readLastLine(Reader reader) throws IOException
      Parameters:
      reader -
      Returns:
      null if the specified file/InputStream/Reader is empty.
      Throws:
      IOException
    • readLine

      public static String readLine(File file, int lineIndex) throws IOException
      Parameters:
      file -
      lineIndex -
      Returns:
      null if line size of the specified file/InputStream/Reader is less than lineIndx + 1.
      Throws:
      IOException
    • readLine

      public static String readLine(File file, int lineIndex, Charset encoding) throws IOException
      Parameters:
      file -
      lineIndex -
      encoding -
      Returns:
      null if line size of the specified file/InputStream/Reader is less than lineIndx + 1.
      Throws:
      IOException
    • readLine

      public static String readLine(InputStream is, int lineIndex) throws IOException
      Parameters:
      is -
      lineIndex -
      Returns:
      null if line size of the specified file/InputStream/Reader is less than lineIndx + 1.
      Throws:
      IOException
    • readLine

      public static String readLine(InputStream is, int lineIndex, Charset encoding) throws IOException
      Parameters:
      is -
      lineIndex -
      encoding -
      Returns:
      null if line size of the specified file/InputStream/Reader is less than lineIndx + 1.
      Throws:
      IOException
    • readLine

      public static String readLine(Reader reader, int lineIndex) throws IOException
      Parameters:
      reader -
      lineIndex -
      Returns:
      null if line size of the specified file/InputStream/Reader is less than lineIndx + 1.
      Throws:
      IOException
    • readLines

      @Deprecated public static List<String> readLines(File file) throws UncheckedIOException
      Deprecated.
      replaced by readAllLines(File)

      Note: It should not be used to read File/InputStream/Reader with size closed to Integer.MAX_VALUE.
      Parameters:
      file -
      Returns:
      Throws:
      UncheckedIOException - the unchecked IO exception
    • readLines

      @Deprecated public static List<String> readLines(File file, Charset encoding) throws UncheckedIOException
      Deprecated.

      Note: It should not be used to read File/InputStream/Reader with size closed to Integer.MAX_VALUE.
      Parameters:
      file -
      encoding -
      Returns:
      Throws:
      UncheckedIOException - the unchecked IO exception
    • readLines

      @Deprecated public static List<String> readLines(InputStream is) throws UncheckedIOException
      Deprecated.

      Note: It should not be used to read File/InputStream/Reader with size closed to Integer.MAX_VALUE.
      Parameters:
      is -
      Returns:
      Throws:
      UncheckedIOException - the unchecked IO exception
    • readLines

      @Deprecated public static List<String> readLines(InputStream is, Charset encoding) throws UncheckedIOException
      Deprecated.

      Note: It should not be used to read File/InputStream/Reader with size closed to Integer.MAX_VALUE.
      Parameters:
      is -
      encoding -
      Returns:
      Throws:
      UncheckedIOException - the unchecked IO exception
    • readLines

      @Deprecated public static List<String> readLines(Reader reader) throws UncheckedIOException
      Deprecated.

      Note: It should not be used to read File/InputStream/Reader with size closed to Integer.MAX_VALUE.
      Parameters:
      reader -
      Returns:
      Throws:
      UncheckedIOException - the unchecked IO exception
    • readLines

      public static List<String> readLines(File file, int offset, int count) throws IOException
      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

      public static List<String> readLines(InputStream is, int offset, int count) throws IOException
      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

      public static List<String> readLines(Reader reader, int offset, int count) throws IOException
      Parameters:
      reader -
      offset -
      count -
      Returns:
      Throws:
      IOException
    • read

      public static int read(File file, byte[] buf) throws IOException
      Parameters:
      file -
      buf -
      Returns:
      Throws:
      IOException
    • read

      public static int read(File file, byte[] buf, int off, int len) throws IOException
      Parameters:
      file -
      buf -
      off - the start offset in array b at which the data is written.
      len -
      Returns:
      Throws:
      IOException
    • read

      public static int read(InputStream is, byte[] buf) throws IOException
      Parameters:
      is -
      buf -
      Returns:
      Throws:
      IOException - Signals that an I/O exception has occurred.
    • read

      public static int read(InputStream is, byte[] buf, int off, int len) throws IOException
      Parameters:
      is -
      buf -
      off - the start offset in array b at which the data is written.
      len -
      Returns:
      Throws:
      IOException - Signals that an I/O exception has occurred.
    • read

      public static int read(File file, char[] buf) throws IOException
      Parameters:
      file -
      buf -
      Returns:
      Throws:
      IOException
    • read

      public static int read(File file, char[] buf, Charset charset) throws IOException
      Parameters:
      file -
      buf -
      charset -
      Returns:
      Throws:
      IOException
    • read

      public static int read(File file, char[] buf, int off, int len) throws IOException
      Parameters:
      file -
      buf -
      off - the start offset in array b at which the data is written.
      len -
      Returns:
      Throws:
      IOException
    • read

      public static int read(File file, char[] buf, int off, int len, Charset charset) throws IOException
      Parameters:
      file -
      buf -
      off -
      len -
      charset -
      Returns:
      Throws:
      IOException
    • read

      public static int read(Reader reader, char[] buf) throws IOException
      Parameters:
      reader -
      buf -
      Returns:
      Throws:
      IOException - Signals that an I/O exception has occurred.
    • read

      public static int read(Reader reader, char[] buf, int off, int len) throws IOException
      Parameters:
      reader -
      buf -
      off - the start offset in array b at which the data is written.
      len -
      Returns:
      Throws:
      IOException - Signals that an I/O exception has occurred.
    • writeLine

      public static void writeLine(File file, Object obj) throws IOException
      Parameters:
      file -
      obj -
      Throws:
      IOException
    • writeLine

      public static void writeLine(OutputStream os, Object obj) throws IOException
      Parameters:
      os -
      obj -
      Throws:
      IOException
    • writeLine

      public static void writeLine(OutputStream os, Object obj, boolean flush) throws IOException
      Parameters:
      os -
      obj -
      flush -
      Throws:
      IOException
    • writeLine

      public static void writeLine(Writer writer, Object obj) throws IOException
      Parameters:
      writer -
      obj -
      Throws:
      IOException
    • writeLine

      public static void writeLine(Writer writer, Object obj, boolean flush) throws IOException
      Parameters:
      writer -
      obj -
      flush -
      Throws:
      IOException
    • writeLines

      public static void writeLines(File file, Object[] lines) throws IOException
      Parameters:
      file -
      lines -
      Throws:
      IOException
    • writeLines

      public static void writeLines(File file, Object[] lines, int offset, int count) throws IOException
      Parameters:
      file -
      lines -
      offset -
      count -
      Throws:
      IOException
    • writeLines

      public static void writeLines(OutputStream os, Object[] lines) throws IOException
      Parameters:
      os -
      lines -
      Throws:
      IOException
    • writeLines

      public static void writeLines(OutputStream os, Object[] lines, boolean flush) throws IOException
      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

      public static void writeLines(Writer writer, Object[] lines) throws IOException
      Parameters:
      writer -
      lines -
      Throws:
      IOException
    • writeLines

      public static void writeLines(Writer writer, Object[] lines, boolean flush) throws IOException
      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

      public static void writeLines(File file, Collection<?> lines) throws IOException
      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

      public static void writeLines(OutputStream os, Collection<?> lines) throws IOException
      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

      public static void writeLines(Writer writer, Collection<?> lines) throws IOException
      Parameters:
      writer -
      lines -
      Throws:
      IOException
    • writeLines

      public static void writeLines(Writer writer, Collection<?> lines, boolean flush) throws IOException
      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

      public static void write(Writer writer, boolean b) throws IOException
      Parameters:
      writer -
      b -
      Throws:
      IOException - Signals that an I/O exception has occurred.
    • write

      public static void write(Writer writer, boolean b, boolean flush) throws IOException
      Parameters:
      writer -
      b -
      flush -
      Throws:
      IOException - Signals that an I/O exception has occurred.
    • write

      public static void write(Writer writer, char c) throws IOException
      Parameters:
      writer -
      c -
      Throws:
      IOException - Signals that an I/O exception has occurred.
    • write

      public static void write(Writer writer, char c, boolean flush) throws IOException
      Parameters:
      writer -
      c -
      flush -
      Throws:
      IOException - Signals that an I/O exception has occurred.
    • write

      public static void write(Writer writer, byte b) throws IOException
      Parameters:
      writer -
      b -
      Throws:
      IOException - Signals that an I/O exception has occurred.
    • write

      public static void write(Writer writer, byte b, boolean flush) throws IOException
      Parameters:
      writer -
      b -
      flush -
      Throws:
      IOException - Signals that an I/O exception has occurred.
    • write

      public static void write(Writer writer, short s) throws IOException
      Parameters:
      writer -
      s -
      Throws:
      IOException - Signals that an I/O exception has occurred.
    • write

      public static void write(Writer writer, short s, boolean flush) throws IOException
      Parameters:
      writer -
      s -
      flush -
      Throws:
      IOException - Signals that an I/O exception has occurred.
    • write

      public static void write(Writer writer, int i) throws IOException
      Parameters:
      writer -
      i -
      Throws:
      IOException - Signals that an I/O exception has occurred.
    • write

      public static void write(Writer writer, int i, boolean flush) throws IOException
      Parameters:
      writer -
      i -
      flush -
      Throws:
      IOException - Signals that an I/O exception has occurred.
    • write

      public static void write(Writer writer, long lng) throws IOException
      Parameters:
      writer -
      lng -
      Throws:
      IOException - Signals that an I/O exception has occurred.
    • write

      public static void write(Writer writer, long lng, boolean flush) throws IOException
      Parameters:
      writer -
      lng -
      flush -
      Throws:
      IOException - Signals that an I/O exception has occurred.
    • write

      public static void write(Writer writer, float f) throws IOException
      Parameters:
      writer -
      f -
      Throws:
      IOException - Signals that an I/O exception has occurred.
    • write

      public static void write(Writer writer, float f, boolean flush) throws IOException
      Parameters:
      writer -
      f -
      flush -
      Throws:
      IOException - Signals that an I/O exception has occurred.
    • write

      public static void write(Writer writer, double d) throws IOException
      Parameters:
      writer -
      d -
      Throws:
      IOException - Signals that an I/O exception has occurred.
    • write

      public static void write(Writer writer, double d, boolean flush) throws IOException
      Parameters:
      writer -
      d -
      flush -
      Throws:
      IOException - Signals that an I/O exception has occurred.
    • write

      public static void write(File output, CharSequence str) throws IOException
      Parameters:
      output -
      str -
      Throws:
      IOException
    • write

      public static void write(File output, CharSequence str, Charset charset) throws IOException
      Parameters:
      output -
      str -
      charset -
      Throws:
      IOException
    • write

      public static void write(OutputStream output, CharSequence str) throws IOException
      Parameters:
      output -
      str -
      Throws:
      IOException
    • write

      public static void write(OutputStream output, CharSequence str, Charset charset) throws IOException
      Parameters:
      output -
      str -
      charset -
      Throws:
      IOException
    • write

      public static void write(OutputStream output, CharSequence str, boolean flush) throws IOException
      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

      public static void write(Writer output, CharSequence str) throws IOException
      Parameters:
      output -
      str -
      Throws:
      IOException
    • write

      public static void write(Writer output, CharSequence str, boolean flush) throws IOException
      Parameters:
      output -
      str -
      flush -
      Throws:
      IOException
    • write

      public static void write(File output, char[] chars) throws IOException
      Parameters:
      output -
      chars -
      Throws:
      IOException
    • write

      public static void write(File output, char[] chars, Charset charset) throws IOException
      Parameters:
      output -
      chars -
      charset -
      Throws:
      IOException
    • write

      public static void write(File output, char[] chars, int offset, int len) throws IOException
      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

      public static void write(OutputStream output, char[] chars) throws IOException
      Parameters:
      output -
      chars -
      Throws:
      IOException
    • write

      public static void write(OutputStream output, char[] chars, Charset charset) throws IOException
      Parameters:
      output -
      chars -
      charset -
      Throws:
      IOException
    • write

      public static void write(OutputStream output, char[] chars, int offset, int len) throws IOException
      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

      public static void write(OutputStream output, char[] chars, boolean flush) throws IOException
      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

      public static void write(Writer output, char[] chars) throws IOException
      Parameters:
      output -
      chars -
      Throws:
      IOException
    • write

      public static void write(Writer output, char[] chars, int offset, int len) throws IOException
      Parameters:
      output -
      chars -
      offset -
      len -
      Throws:
      IOException
    • write

      public static void write(Writer output, char[] chars, boolean flush) throws IOException
      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

      public static void write(File output, byte[] bytes) throws IOException
      Parameters:
      output -
      bytes -
      Throws:
      IOException
    • write

      public static void write(File output, byte[] bytes, int offset, int len) throws IOException
      Parameters:
      output -
      bytes -
      offset -
      len -
      Throws:
      IOException
    • write

      public static void write(OutputStream output, byte[] bytes) throws IOException
      Parameters:
      output -
      bytes -
      Throws:
      IOException
    • write

      public static void write(OutputStream output, byte[] bytes, int offset, int len) throws IOException
      Parameters:
      output -
      bytes -
      offset -
      len -
      Throws:
      IOException
    • write

      public static void write(OutputStream output, byte[] bytes, boolean flush) throws IOException
      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

      public static long write(File output, InputStream input) throws IOException
      Parameters:
      output -
      input -
      Returns:
      Throws:
      IOException
    • write

      public static long write(File output, InputStream input, long offset, long len) throws IOException
      Parameters:
      output -
      input -
      offset - by byte
      len - by byte
      Returns:
      Throws:
      IOException
    • write

      public static long write(OutputStream output, InputStream input) throws IOException
      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

      public static long write(OutputStream output, InputStream input, boolean flush) throws IOException
      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 byte
      len - by byte
      flush -
      Returns:
      Throws:
      IOException
    • write

      public static long write(File output, Reader input) throws IOException
      Parameters:
      output -
      input -
      Returns:
      Throws:
      IOException
    • write

      public static long write(File output, Reader input, Charset charset) throws IOException
      Parameters:
      output -
      input -
      charset -
      Returns:
      Throws:
      IOException
    • write

      public static long write(File output, Reader input, long offset, long len) throws IOException
      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 char
      len - by char
      charset -
      Returns:
      Throws:
      IOException
    • write

      public static long write(Writer output, Reader input) throws IOException
      Parameters:
      output -
      input -
      Returns:
      Throws:
      IOException
    • write

      public static long write(Writer output, Reader input, long offset, long len) throws IOException
      Parameters:
      output -
      input -
      offset -
      len -
      Returns:
      Throws:
      IOException
    • write

      public static long write(Writer output, Reader input, boolean flush) throws IOException
      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 char
      len - by char
      flush -
      Returns:
      Throws:
      IOException
    • write

      public static long write(File output, File input) throws IOException
      Parameters:
      output -
      input -
      Returns:
      Throws:
      IOException
    • write

      public static long write(File output, File input, long offset, long len) throws IOException
      Parameters:
      output -
      input -
      offset -
      len -
      Returns:
      Throws:
      IOException
    • write

      public static long write(OutputStream output, File input) throws IOException
      Parameters:
      output -
      input -
      Returns:
      Throws:
      IOException
    • write

      public static long write(OutputStream output, File input, long offset, long len) throws IOException
      Parameters:
      output -
      input -
      offset -
      len -
      Returns:
      Throws:
      IOException
    • write

      public static long write(OutputStream output, File input, boolean flush) throws IOException
      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 byte
      len - by byte
      flush -
      Returns:
      Throws:
      IOException
    • write

      public static long write(Writer output, File input) throws IOException
      Parameters:
      output -
      input -
      Returns:
      Throws:
      IOException
    • write

      public static long write(Writer output, File input, long offset, long len) throws IOException
      Parameters:
      output -
      input -
      offset -
      len -
      Returns:
      Throws:
      IOException
    • write

      public static long write(Writer output, File input, boolean flush) throws IOException
      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 char
      len - by char
      flush -
      Returns:
      Throws:
      IOException
    • append

      public static void append(File output, byte[] bytes) throws IOException
      Parameters:
      output -
      bytes -
      Throws:
      IOException
    • append

      public static void append(File output, byte[] bytes, int offset, int len) throws IOException
      Parameters:
      output -
      bytes -
      offset -
      len -
      Throws:
      IOException
    • append

      public static void append(File output, char[] chars) throws IOException
      Parameters:
      output -
      chars -
      Throws:
      IOException
    • append

      public static void append(File output, char[] chars, Charset charset) throws IOException
      Parameters:
      output -
      chars -
      charset -
      Throws:
      IOException
    • append

      public static void append(File output, char[] chars, int offset, int len) throws IOException
      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

      public static void append(File output, CharSequence str) throws IOException
      Parameters:
      output -
      str -
      Throws:
      IOException
    • append

      public static void append(File output, CharSequence str, Charset charset) throws IOException
      Parameters:
      output -
      str -
      charset -
      Throws:
      IOException
    • append

      public static long append(File output, InputStream input) throws IOException
      Parameters:
      output -
      input -
      Returns:
      Throws:
      IOException
    • append

      public static long append(File output, InputStream input, long offset, long len) throws IOException
      Parameters:
      output -
      input -
      offset - by byte
      len - by byte
      Returns:
      Throws:
      IOException
    • append

      public static long append(File output, Reader input) throws IOException
      Parameters:
      output -
      input -
      Returns:
      Throws:
      IOException
    • append

      public static long append(File output, Reader input, Charset charset) throws IOException
      Parameters:
      output -
      input -
      charset -
      Returns:
      Throws:
      IOException
    • append

      public static long append(File output, Reader input, long offset, long len) throws IOException
      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 char
      len - by char
      charset -
      Returns:
      Throws:
      IOException
    • append

      public static long append(File output, File input) throws IOException
      Parameters:
      output -
      input -
      Returns:
      Throws:
      IOException
    • append

      public static long append(File output, File input, long offset, long len) throws IOException
      Parameters:
      output -
      input -
      offset -
      len -
      Returns:
      Throws:
      IOException
    • appendLine

      public static void appendLine(File output, CharSequence str) throws IOException
      Parameters:
      output -
      str -
      Throws:
      IOException
    • appendLine

      public static void appendLine(File output, CharSequence str, Charset charset) throws IOException
      Parameters:
      output -
      str -
      charset -
      Throws:
      IOException
    • skip

      public static long skip(InputStream input, long toSkip) throws IOException
      Return the count of skipped bytes.
      Parameters:
      input -
      toSkip -
      Returns:
      Throws:
      IOException
    • skip

      public static long skip(Reader input, long toSkip) throws IOException
      Return the count of skipped chars.
      Parameters:
      input -
      toSkip -
      Returns:
      Throws:
      IOException
    • skipFully

      public static void skipFully(InputStream input, long toSkip) throws IOException
      Parameters:
      input -
      toSkip -
      Throws:
      IOException - if the remaining length of the specified input is less than the specified toSkip
    • skipFully

      public static void skipFully(Reader input, long toSkip) throws IOException
      Parameters:
      input -
      toSkip -
      Throws:
      IOException - if the remaining length of the specified input is less than the specified toSkip
    • map

      public static MappedByteBuffer map(File file) throws IOException
      Note: copied from Google Guava under Apache License v2.
      Parameters:
      file -
      Returns:
      Throws:
      IOException
    • map

      public static MappedByteBuffer map(File file, FileChannel.MapMode mode) throws IOException
      Note: copied from Google Guava under Apache License v2. Fully maps a file in to memory as per FileChannel.map(java.nio.channels.FileChannel.MapMode, long, long) using the requested FileChannel.MapMode.

      Files are mapped from offset 0 to its length.

      This only works for files <= Integer.MAX_VALUE bytes.

      Parameters:
      file - the file to map
      mode - the mode to use when mapping file
      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 per FileChannel.map(java.nio.channels.FileChannel.MapMode, long, long) using the requested FileChannel.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 requested size. Thus this method is useful for creating memory mapped files which do not yet exist.

      This only works for files <= Integer.MAX_VALUE bytes.

      Parameters:
      file - the file to map
      mode - the mode to use when mapping file
      offset -
      len -
      Returns:
      a buffer reflecting file
      Throws:
      IOException
      Since:
      2.0
      See Also:
    • simplifyPath

      public static String simplifyPath(String pathname)
      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, which simplifyPath will change to b. If a is a symlink to x, a/../b may refer to a sibling of x, rather than the sibling of a referred to by b.

      Parameters:
      pathname -
      Returns:
      Since:
      11.0
    • getFileExtension

      public static String getFileExtension(String fullName)
      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

      public static String getNameWithoutExtension(String file)
      Note: copied from Google Guava under Apache License v2. Returns the file name without its file extension or path. This is similar to the basename 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
    • newFileOutputStream

      public static FileOutputStream newFileOutputStream(File file) throws UncheckedIOException
      Parameters:
      file -
      Returns:
      Throws:
      UncheckedIOException
    • newFileInputStream

      public static FileInputStream newFileInputStream(File file) throws UncheckedIOException
      Parameters:
      file -
      Returns:
      Throws:
      UncheckedIOException
    • newFileOutputStream

      public static FileOutputStream newFileOutputStream(String name) throws UncheckedIOException
      Parameters:
      name -
      Returns:
      Throws:
      UncheckedIOException
    • newFileReader

      public static FileReader newFileReader(File file) throws UncheckedIOException
      Parameters:
      file -
      Returns:
      Throws:
      UncheckedIOException
    • newFileReader

      public static FileReader newFileReader(File file, Charset charset) throws UncheckedIOException
      Parameters:
      file -
      charset -
      Returns:
      Throws:
      UncheckedIOException
    • newFileWriter

      public static FileWriter newFileWriter(File file) throws UncheckedIOException
      Parameters:
      file -
      Returns:
      Throws:
      UncheckedIOException
    • newFileWriter

      public static FileWriter newFileWriter(File file, Charset charset) throws UncheckedIOException
      Parameters:
      file -
      charset -
      Returns:
      Throws:
      UncheckedIOException
    • newBufferedReader

      public static BufferedReader newBufferedReader(File file) throws UncheckedIOException
      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

      public static BufferedReader newBufferedReader(Path path) throws UncheckedIOException
      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

      public static BufferedReader newBufferedReader(InputStream is) throws UncheckedIOException
      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

      public static BufferedWriter newBufferedWriter(File file) throws UncheckedIOException
      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

      public static BufferedWriter newBufferedWriter(OutputStream os)
      New buffered writer.
      Parameters:
      os -
      Returns:
    • newBufferedWriter

      public static BufferedWriter newBufferedWriter(OutputStream os, Charset charset)
      New buffered writer.
      Parameters:
      os -
      charset -
      Returns:
    • newLZ4BlockInputStream

      public static LZ4BlockInputStream newLZ4BlockInputStream(InputStream is)
      New LZ 4 block input stream.
      Parameters:
      is -
      Returns:
    • newLZ4BlockOutputStream

      public static LZ4BlockOutputStream newLZ4BlockOutputStream(OutputStream os)
      New LZ 4 block output stream.
      Parameters:
      os -
      Returns:
    • newLZ4BlockOutputStream

      public static LZ4BlockOutputStream newLZ4BlockOutputStream(OutputStream os, int blockSize)
      Creates a new input stream with the specified buffer size.
      Parameters:
      os -
      blockSize -
      Returns:
    • newSnappyInputStream

      public static SnappyInputStream newSnappyInputStream(InputStream is) throws UncheckedIOException
      New snappy input stream.
      Parameters:
      is -
      Returns:
      Throws:
      UncheckedIOException - the unchecked IO exception
    • newSnappyOutputStream

      public static SnappyOutputStream newSnappyOutputStream(OutputStream os)
      New snappy output stream.
      Parameters:
      os -
      Returns:
    • newSnappyOutputStream

      public static SnappyOutputStream newSnappyOutputStream(OutputStream os, int bufferSize)
      Creates a new input stream with the specified buffer size.
      Parameters:
      os -
      bufferSize -
      Returns:
    • newGZIPInputStream

      public static GZIPInputStream newGZIPInputStream(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

      public static GZIPOutputStream newGZIPOutputStream(OutputStream os) throws UncheckedIOException
      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
    • newBrotliInputStream

      public static BrotliInputStream newBrotliInputStream(InputStream is) throws UncheckedIOException
      New GZIP input stream.
      Parameters:
      is -
      Returns:
      Throws:
      UncheckedIOException - the unchecked IO exception
    • close

      public static void close(AutoCloseable closeable)
      Parameters:
      closeable -
    • closeAll

      @SafeVarargs public static void closeAll(AutoCloseable... a)
      Parameters:
      a -
    • closeAll

      public static void closeAll(Collection<? extends AutoCloseable> c)
      Parameters:
      c -
    • closeQuietly

      public static void closeQuietly(AutoCloseable closeable)
      Parameters:
      closeable -
    • closeAllQuietly

      @SafeVarargs public static void closeAllQuietly(AutoCloseable... a)
      Close all quietly.
      Parameters:
      a -
    • closeAllQuietly

      public static void closeAllQuietly(Collection<? extends AutoCloseable> c)
      Close all quietly.
      Parameters:
      c -
    • copyFileToDirectory

      public static void copyFileToDirectory(File srcFile, File destDir) throws UncheckedIOException
      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,E> filter) throws UncheckedIOException, E
      Copy the specified scrFile if it's a file or its sub files/directories if it's a directory to the target destDir with the specified filter.
      Type Parameters:
      E -
      Parameters:
      srcFile -
      destDir -
      preserveFileDate -
      filter -
      Throws:
      UncheckedIOException - the unchecked IO exception
      E - 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

      public static long copy(Path source, OutputStream output) throws UncheckedIOException
      Parameters:
      source -
      output -
      Returns:
      Throws:
      UncheckedIOException - the unchecked IO exception
      See Also:
    • copyURLToFile

      public static void copyURLToFile(URL source, File destination) throws UncheckedIOException
      Copies bytes from the URL source to a file destination. The directories up to destination 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 - the URL to copy bytes from, must not be null
      destination - the non-directory File to write bytes to (possibly overwriting), must not be null
      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 URL source to a file destination. The directories up to destination will be created if they don't already exist. destination will be overwritten if it already exists.
      Parameters:
      source - the URL to copy bytes from, must not be null
      destination - the non-directory File to write bytes to (possibly overwriting), must not be null
      connectionTimeout - the number of milliseconds until this method will timeout if no connection could be established to the source
      readTimeout - the number of milliseconds until this method will timeout if no data could be read from the source
      Throws:
      UncheckedIOException - if an IO error occurs during copying
    • move

      public static void move(File srcFile, File destDir) throws UncheckedIOException
      Parameters:
      srcFile -
      destDir -
      Throws:
      UncheckedIOException - the unchecked IO exception
    • renameTo

      public static boolean renameTo(File srcFile, String newFileName)
      Parameters:
      srcFile -
      newFileName -
      Returns:
      true if and only if the renaming succeeded; false otherwise
    • deleteIfExists

      public static boolean deleteIfExists(File file)
      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.
      See Also:
    • deleteAllIfExists

      public static boolean deleteAllIfExists(File file)
      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.
      See Also:
    • deleteFiles

      public static boolean deleteFiles(File dir)
      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,E> filter) throws E
      Delete the specified dir 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
      See Also:
    • cleanDirectory

      public static boolean cleanDirectory(File directory)
      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

      public static boolean createIfNotExists(File file) throws UncheckedIOException
      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

      public static boolean mkdirIfNotExists(File dir)
      Parameters:
      dir -
      Returns:
    • mkdirsIfNotExists

      public static boolean mkdirsIfNotExists(File dir)
      Parameters:
      dir -
      Returns:
    • isFileNewer

      public static boolean isFileNewer(File file, Date date)
      Tests if the specified File is newer than the specified Date.
      Parameters:
      file - the File of which the modification date must be compared
      date - the date reference
      Returns:
      true if the File exists and has been modified after the given Date.
      Throws:
      IllegalArgumentException - if the file or date is null
    • isFileNewer

      public static boolean isFileNewer(File file, File reference)
      Tests if the specified File is newer than the reference File.
      Parameters:
      file - the File of which the modification date must be compared
      reference - the File of which the modification date is used
      Returns:
      true if the File exists and has been modified more recently than the reference File
      Throws:
      IllegalArgumentException - if the file or reference file is null or the reference file doesn't exist
    • isFileOlder

      public static boolean isFileOlder(File file, Date date)
      Tests if the specified File is older than the specified Date.
      Parameters:
      file - the File of which the modification date must be compared
      date - the date reference
      Returns:
      true if the File exists and has been modified before the given Date
      Throws:
      IllegalArgumentException - if the file or date is null
    • isFileOlder

      public static boolean isFileOlder(File file, File reference)
      Tests if the specified File is older than the reference File.
      Parameters:
      file - the File of which the modification date must be compared
      reference - the File of which the modification date is used
      Returns:
      true if the File exists and has been modified before the reference File
      Throws:
      IllegalArgumentException - if the file or reference file is null or the reference file doesn't exist
    • isSymbolicLink

      public static boolean isSymbolicLink(File file)
      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 using 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

      public static long sizeOf(File file)
      Returns the size of the specified file or directory. If the provided File 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 #sizeOfAsBigInteger(File) for an alternative method that does not overflow.

      Parameters:
      file - the regular file or directory to return the size of (must not be null).
      Returns:
      the length of the file, or recursive size of the directory, provided (in bytes).
      Throws:
      IllegalArgumentException - if the file is null or the file does not exist.
      Since:
      2.0
    • sizeOfDirectory

      public static long sizeOfDirectory(File directory)
      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 #sizeOfDirectoryAsBigInteger(File) for an alternative method that does not overflow.

      Parameters:
      directory - directory to inspect, must not be null
      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 is null or it's not existed directory.
    • zip

      public static void zip(File sourceFile, File targetFile) throws UncheckedIOException
      Parameters:
      sourceFile -
      targetFile -
      Throws:
      UncheckedIOException - the unchecked IO exception
    • zip

      public static void zip(Collection<File> sourceFiles, File targetFile) throws UncheckedIOException
      Parameters:
      sourceFiles -
      targetFile -
      Throws:
      UncheckedIOException - the unchecked IO exception
    • unzip

      public static void unzip(File srcZipFile, File targetDir)
      Parameters:
      srcZipFile -
      targetDir -
    • split

      public static void split(File file, int countOfParts) throws UncheckedIOException
      Parameters:
      file -
      countOfParts -
      Throws:
      UncheckedIOException - the unchecked IO exception
    • split

      public static void split(File file, int countOfParts, File destDir) throws UncheckedIOException
      Parameters:
      file -
      countOfParts -
      destDir -
      Throws:
      UncheckedIOException - the unchecked IO exception
    • splitBySize

      public static void splitBySize(File file, long sizeOfPart) throws UncheckedIOException
      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

      public static long merge(File[] sourceFiles, File destFile) throws UncheckedIOException
      Parameters:
      sourceFiles -
      destFile -
      Returns:
      Throws:
      UncheckedIOException - the unchecked IO exception
    • merge

      public static long merge(Collection<File> sourceFiles, File destFile) throws UncheckedIOException
      Merge the specified source files into the destination file.
      Parameters:
      sourceFiles -
      destFile -
      Returns:
      Throws:
      UncheckedIOException - the unchecked IO exception
    • list

      public static List<String> list(File parentPath)
      Parameters:
      parentPath -
      Returns:
    • list

      public static List<String> list(File parentPath, boolean recursively, boolean excludeDirectory)
      Parameters:
      parentPath -
      recursively -
      excludeDirectory -
      Returns:
    • list

      public static <E extends Exception> List<String> list(File parentPath, boolean recursively, Throwables.BiPredicate<? super File,? super File,E> filter) throws E
      Type Parameters:
      E -
      Parameters:
      parentPath -
      recursively -
      filter -
      Returns:
      Throws:
      E - the e
    • listFiles

      public static List<File> listFiles(File parentPath)
      Parameters:
      parentPath -
      Returns:
    • listFiles

      public static List<File> listFiles(File parentPath, boolean recursively, boolean excludeDirectory)
      Parameters:
      parentPath -
      recursively -
      excludeDirectory -
      Returns:
    • listFiles

      public static <E extends Exception> List<File> listFiles(File parentPath, boolean recursively, Throwables.BiPredicate<? super File,? super File,E> filter) throws E
      Type Parameters:
      E -
      Parameters:
      parentPath -
      recursively -
      filter -
      Returns:
      Throws:
      E - the e
    • listDirectories

      public static List<File> listDirectories(File parentPath)
      Parameters:
      parentPath -
      Returns:
    • listDirectories

      public static List<File> listDirectories(File parentPath, boolean recursively)
      Parameters:
      parentPath -
      recursively -
      Returns:
    • toFile

      public static File toFile(URL url)
      Convert from a URL to a File.

      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 returns null
      Returns:
      Throws:
      NullPointerException - if the parameter is null
    • toFiles

      public static File[] toFiles(URL[] urls) throws UncheckedIOException
      Converts each of an array of URL to a File.

      Returns an array of the same size as the input. If the input is null, an empty array is returned. If the input contains null, the output array contains null 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 a null item if there was a null at that index in the input array
      Throws:
      UncheckedIOException - the unchecked IO exception
      IllegalArgumentException - if any file is incorrectly encoded
      Since:
      1.1
    • toFiles

      public static List<File> toFiles(Collection<URL> urls) throws UncheckedIOException
      Parameters:
      urls -
      Returns:
      Throws:
      UncheckedIOException - the unchecked IO exception
    • toURL

      public static URL toURL(File file) throws UncheckedIOException
      Parameters:
      file -
      Returns:
      Throws:
      UncheckedIOException - the unchecked IO exception
    • toURLs

      public static URL[] toURLs(File[] files) throws UncheckedIOException
      To UR ls.
      Parameters:
      files -
      Returns:
      Throws:
      UncheckedIOException - the unchecked IO exception
    • toURLs

      public static List<URL> toURLs(Collection<File> files) throws UncheckedIOException
      To UR ls.
      Parameters:
      files -
      Returns:
      Throws:
      UncheckedIOException - the unchecked IO exception
    • touch

      public static boolean touch(File file)
      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 exception
      E - 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 exception
      E - the e
      E2 - 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 exception
      E - 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 exception
      E - the e
      E2 - 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 exception
      E - 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, E2
      Parse 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/records
      queueSize -
      lineParser -
      onComplete -
      Throws:
      UncheckedIOException - the unchecked IO exception
      E - the e
      E2 - 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 exception
      E - 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 exception
      E - the e
      E2 - 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 exception
      E - 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 exception
      E - the e
      E2 - 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 exception
      E - 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, E2
      Parse 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/records
      queueSize - size of queue to save the processing records/lines loaded from source data. Default size is 1024.
      lineParser -
      onComplete -
      Throws:
      UncheckedIOException - the unchecked IO exception
      E - the e
      E2 - 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 exception
      E - 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 exception
      E - the e
      E2 - 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 exception
      E - 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, E2
      Parse 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/records
      processThreadNum - new threads started to parse/process the lines/records
      queueSize - size of queue to save the processing records/lines loaded from source data. Default size is 1024.
      lineParser -
      onComplete -
      Throws:
      UncheckedIOException - the unchecked IO exception
      E - the e
      E2 - 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 exception
      E - 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 exception
      E - the e
      E2 - 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 exception
      E - 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, E2
      Parse 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/records
      processThreadNum - new threads started to parse/process the lines/records
      queueSize - size of queue to save the processing records/lines loaded from source data. Default size is 1024.
      lineParser -
      onComplete -
      Throws:
      UncheckedIOException - the unchecked IO exception
      E - the e
      E2 - 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 exception
      E - 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 exception
      E - the e
      E2 - 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 exception
      E - 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 exception
      E - the e
      E2 - 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 exception
      E - 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, E2
      Parse the specified Reader line by line.
      Type Parameters:
      E -
      E2 -
      Parameters:
      is -
      lineOffset -
      count -
      processThreadNum - new threads started to parse/process the lines/records
      queueSize - size of queue to save the processing records/lines loaded from source data. Default size is 1024.
      lineParser -
      onComplete -
      Throws:
      UncheckedIOException - the unchecked IO exception
      E - the e
      E2 - 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 exception
      E - 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 exception
      E - the e
      E2 - 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 exception
      E - 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 exception
      E - the e
      E2 - 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 exception
      E - 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, E2
      Parse the specified Reader line by line.
      Type Parameters:
      E -
      E2 -
      Parameters:
      reader -
      lineOffset -
      count -
      processThreadNum - new threads started to parse/process the lines/records
      queueSize - size of queue to save the processing records/lines loaded from source data. Default size is 1024.
      lineParser -
      onComplete -
      Throws:
      UncheckedIOException - the unchecked IO exception
      E - the e
      E2 - the e2