public class

IO

extends Object
java.lang.Object
   ↳ com.pnfsoftware.jeb.util.io.IO

Class Overview

File manipulation routines.

Summary

Constants
int MAX_FILENAME_SIZE Maximum filename size used in JEB (255 allowed for Linux, 259 for Windows file)
int MAX_PATH_SIZE Maximum foldername size used in JEB (248 for Windows folder)
Public Constructors
IO()
Public Methods
static String abs(File file)
Provide an absolute simplified path.
static String abs(String path)
Provide an absolute simplified path.
static void addFileToJar(JarOutputStream jar, File file, String entryName)
Add a new entry to a a jar output stream.
static void addFileToZip(ZipOutputStream zip, File file, String entryName)
Add a new entry to a a zip output stream.
static boolean checkFileFreshness(File file, long millis, boolean cleanStaleFile)
static boolean compareFiles(File file0, File file1)
Compare the contents of two files for equality.
static boolean compressFolder(String folderPath, String zipfilePath)
Compress a folder and its contents to a zip archive.
static Thread copyAsync(InputStream input, OutputStream output)
Copy a continuous stream of data from a source to a destination.
static void copyFile(File src, File dst, boolean overwrite)
Copy a source file to a destination.
static long copyStream(InputStream input, OutputStream output)
Read bytes from an input stream and dump them to an output stream.@return
static long copyStream(InputStream input, OutputStream output, byte[] buffer)
Read bytes from an input stream and dump them to an output stream.@return
static boolean createDirectory(String path)
Safely create a directory.
static boolean createDirectory(File f)
Safely create a directory.
static boolean createFile(File file, boolean createDirs)
Create an empty file.
static File createFolder(String path)
Create or retrieve a directory.
static void createFoldersForFile(File file)
Create the directory structure needed to store a file.
static File createSafeTempFile()
Create an empty file in the safe temporary area.
static File createTempFile(String exactname)
Create a file (with an exact name) in the default temp folder.
static File createTempFile()
Create an empty file in the temporary folder.
static File createTempFile(String basename, String extension)
Create a file in the default temp folder.@return
static File createTempFileNumbered(String name)
Create a new file with the provided name in the default temp folder.
static File createTempFolder(String folderName)
Create a directory in the default temporary-file directory.
static boolean deleteDirectory(File dir)
Delete a directory and its contents recursively.
static boolean deleteDirectory(String path)
Delete a directory and its contents recursively.
static boolean deleteDirectoryContents(File dir)
Delete a directory contents recursively (ie, clear the directory).
static void deleteDirectoryOnExit(File dir)
Delete a folder and all its contents recursively, when the virtual machine terminates.
static boolean deleteFile(File file)
Delete a file.
static String escapeFileName(String filename)
Escape filename invalid characters with an underscore.
static String escapeFileName(String filename, char newChar)
Escape illegal characters in filename by the provided char.
static String escapeFileNameStrict(String filename, char newChar)
Create a valid filename from any string.
static String escapeFileNameStrict(String filename)
Create a valid filename with an underscore for non alphanumeric char, '-', '_', '.' nor '''.
static String expandPath(String path)
Perform expansion of certain shell artifacts used in path names.
static void extractToFolder(File inputZipFile, File outputFolder)
Extract the contents of a zip archive to a target folder.
static String getCwd()
Get the path of the current working directory.
static String getExtension(String path)
Extract the extension of a file path.
static String getExtension(File file)
Extract the extension of a file path.
static byte getFirstByte(String path)
Get the first byte of a file.
static int getFirstIntLE(String path)
Get the first 4-byte of a file, read as a little-endian integer.
static short getFirstShortLE(String path)
Get the first 2-byte of a file, read as a little-endian short.
static File getHomeFolder()
Retrieve the current user's home folder.
static String getOriginalCwd()
Get original working directory, i.e.
static File getParentFile2(File file)
A safer implementation of getParentFile().
static String getRelativePath(File file, File base)
Provide the path to a file relative to a base.
static File getSafeTempFolder()
Retrieve the JEB session specific temp folder in the user's temporary folder.
static File getTempFolder()
Retrieve the temporary folder.
static boolean inFolder(File file, File folder)
Determine if a hypothetical file would be contained within a hypothetical folder, i.e.
static boolean isFile(String path)
Determine if a path refers to an existing file.
static boolean isUrl(String s)
Determine whether the provided input string looks like a URL.
static List<File> listFiles(String folderpath)
Recursively do a directory listing.
static List<File> listFiles(File folder)
Recursively do a directory listing.
static void mkdirs2(File dir)
Create a directory and its parents.
static boolean mkdirs2Ex(File dir)
Create a directory and its parents.
static String noExtension(String path)
static File noExtension(File file)
static List<String> parsePathElements(String s)
Parse the elements of a path.
static byte[] readFile(String path)
Read the contents of a binary file.@return
static byte[] readFile(File file, long maxAllowedSize)
Read the contents of a binary file.@return
static byte[] readFile(File file)
Read the contents of a binary files.@return
static byte[] readFileSafe(File file)
Read a binary file safely.
static String readInputLine()
Read a line from the standard input.@return
static String readInputLineSafe()
Read a line from the standard input.
static byte[] readInputStream(InputStream in)
Read and reliably return all bytes of an input stream.
static List<String> readLines(InputStream input)
Read the contents of a stream as a text buffer of UTF-8 encoded strings.@return
static List<String> readLines(File file)
Read the UTF-8 encoded lines of a text file.@return
static List<String> readLines(File file, Charset encoding)
Read the lines of a text file.@return
static List<String> readLines(InputStream input, Charset encoding)
Read the contents of a stream as a line of strings.
static List<String> readLinesSafe(File file, Charset encoding)
Read the lines of a text file.
static List<String> readLinesSafe(File file)
Read the lines of a UTF8 encoded text file.
static boolean renameFile(File src, File dst, int mode)
Rename a file with options.
static File replaceExtension(File file, String extension)
static String sanitizePath(String path, boolean isSinglePathElement, boolean replaceBlankCharacters)
Sanitize a path.
static String sanitizePathUnsafe(String path)
Attempt to sanitize a path.
static String setCwd(String cwd)
Set the path of the current working directory.
static String simplifyPath(String path)
Simplify a path.
static String simplifyPathUnix(String path)
static String simplifyPathWindows(String path)
static String[] splitExtension(String path)
Split a file path into its extension-less part and its extension.
static String[] splitPath(String path)
Split a path into its base part and its filename part.
static void writeFile(File file, String str)
Write a string to a file using the default character encoding of the current system.
static void writeFile(File file, byte[] data, boolean createDirs)
Write data to a file whose containing directory structure may not exist.
static void writeFile(File file, byte[] data, int offset, int size)
Write data to a file.
static void writeFile(File file, String str, String charsetName)
Write a string to a file using the given character encoding of the current system.
static void writeFile(File file, byte[] data, int offset, int size, boolean createDirs)
Write data to a file whose containing directory structure may not exist.
static void writeFile(File file, byte[] data)
Write data to a file.
static boolean writeFileSafe(File file, byte[] data, int offset, int size, boolean createDirs)
Write a binary file safely.
static boolean writeFileSafe(File file, byte[] data, boolean createDirs)
Write a binary file safely.
static void writeLines(OutputStream output, List<? extends CharSequence> lines)
Write UTF-8 encoded strings.
static void writeLines(File file, List<? extends CharSequence> lines)
Write UTF-8 encoded strings.
static void writeLines(OutputStream output, List<? extends CharSequence> lines, Charset encoding)
Write strings.
static void writeLines(File file, List<? extends CharSequence> lines, Charset encoding)
Write strings.
static boolean writeLinesSafe(OutputStream output, List<? extends CharSequence> lines)
Write UTF-8 encoded strings.
static boolean writeLinesSafe(File file, List<? extends CharSequence> lines, Charset encoding)
Write strings.
static boolean writeLinesSafe(OutputStream output, List<? extends CharSequence> lines, Charset encoding)
Write strings.
static boolean writeLinesSafe(File file, List<? extends CharSequence> lines)
Write UTF-8 encoded strings.
[Expand]
Inherited Methods
From class java.lang.Object

Constants

public static final int MAX_FILENAME_SIZE

Maximum filename size used in JEB (255 allowed for Linux, 259 for Windows file)

Constant Value: 255 (0x000000ff)

public static final int MAX_PATH_SIZE

Maximum foldername size used in JEB (248 for Windows folder)

Constant Value: 248 (0x000000f8)

Public Constructors

public IO ()

Public Methods

public static String abs (File file)

Provide an absolute simplified path. This method is OS-dependent.

Rules:
- . and .. uses are resolved.
- Multiple-path separator uses such as /// or \\ are resolved.
- Redundant trailing separators are removed.
- The empty path is always resolved to ..
- If the FS is case-insensitive (e.g. NTFS), the case is not standardized (Windows).
- Symbolic links are not resolved.

Parameters
file input file
Returns
  • absolute simplified path

public static String abs (String path)

Provide an absolute simplified path. This method is OS-dependent.

Rules:
- . and .. uses are resolved.
- Multiple-path separator uses such as /// or \\ are resolved.
- Redundant trailing separators are removed.
- The empty path is always resolved to ..
- If the FS is case-insensitive (e.g. NTFS), the case is not standardized (Windows).
- Symbolic links are not resolved.

Parameters
path input path
Returns
  • absolute simplified path

public static void addFileToJar (JarOutputStream jar, File file, String entryName)

Add a new entry to a a jar output stream.

Throws
IOException

public static void addFileToZip (ZipOutputStream zip, File file, String entryName)

Add a new entry to a a zip output stream.

Throws
IOException

public static boolean checkFileFreshness (File file, long millis, boolean cleanStaleFile)

Returns
  • true if the file exists and its last modification timestamp is less than millis ms old

public static boolean compareFiles (File file0, File file1)

Compare the contents of two files for equality.

Parameters
file0 first file
file1 second file
Throws
FileNotFoundException one of the input file is not found
IOException other IO exception

public static boolean compressFolder (String folderPath, String zipfilePath)

Compress a folder and its contents to a zip archive.

Parameters
folderPath input folder
zipfilePath output zip file path
Returns
  • true on success

public static Thread copyAsync (InputStream input, OutputStream output)

Copy a continuous stream of data from a source to a destination. This method is non-blocking.

Parameters
input the source input stream
output the destination output stream
Returns
  • the daemon worker thread in charge of copying the data

public static void copyFile (File src, File dst, boolean overwrite)

Copy a source file to a destination.

Parameters
src source file (not a directory)
dst destination file or directory
overwrite if true, the destination file may be overwritten if it already exists
Throws
FileNotFoundException the source is not found
FileAlreadyExistsException the destination would be overwritten
IOException other IO exception

public static long copyStream (InputStream input, OutputStream output)

Read bytes from an input stream and dump them to an output stream.@return

Throws
IOException

public static long copyStream (InputStream input, OutputStream output, byte[] buffer)

Read bytes from an input stream and dump them to an output stream.@return

Parameters
buffer recommended use: multiple of 0x1000
Throws
IOException

public static boolean createDirectory (String path)

Safely create a directory.

Returns
  • true on success, else false

public static boolean createDirectory (File f)

Safely create a directory.

public static boolean createFile (File file, boolean createDirs)

Create an empty file.

Parameters
createDirs if true, the directory structure needed to contain the file will also be created
Returns
  • true if the named file does not exist and was successfully created; false if the named file already exists
Throws
IOException

public static File createFolder (String path)

Create or retrieve a directory.

Parameters
path directory path
Returns
  • the directory file object
Throws
IOException on creation error

public static void createFoldersForFile (File file)

Create the directory structure needed to store a file.

Parameters
file a file
Throws
IOException

public static File createSafeTempFile ()

Create an empty file in the safe temporary area.

Returns
  • the file
Throws
IOException on file creation error

public static File createTempFile (String exactname)

Create a file (with an exact name) in the default temp folder.

Parameters
exactname exact file name
Returns
  • the file object (the file itself may or may not exist when the method returns)
Throws
IOException

public static File createTempFile ()

Create an empty file in the temporary folder.

Returns
  • the file
Throws
IOException on file creation error

public static File createTempFile (String basename, String extension)

Create a file in the default temp folder.@return

Parameters
basename optional base name
extension optional extension (suffix)
Throws
IOException

public static File createTempFileNumbered (String name)

Create a new file with the provided name in the default temp folder. If a file with the provided name already exists, counter-suffixed names are tried (NAME.1, NAME.2, etc.) until the first non-existent entry is found.

Parameters
name desired file name
Returns
  • the file object (the file itself does not exist at the time this method returns)
Throws
IOException

public static File createTempFolder (String folderName)

Create a directory in the default temporary-file directory.

Parameters
folderName optional folder name; if null, a randomly named folder will be created
Returns
  • a File representing the newly created directory, or null on error
Throws
IOException if an IO exception happened

public static boolean deleteDirectory (File dir)

Delete a directory and its contents recursively.

Returns
  • true on success, false if errors were encountered; note that some files and directories may have been deleted

public static boolean deleteDirectory (String path)

Delete a directory and its contents recursively.

Returns
  • true on success

public static boolean deleteDirectoryContents (File dir)

Delete a directory contents recursively (ie, clear the directory). The directory itself is not deleted.

Returns
  • true on success, false if errors were encountered; note that some files and directories may have been deleted

public static void deleteDirectoryOnExit (File dir)

Delete a folder and all its contents recursively, when the virtual machine terminates.

Parameters
dir folder to be deleted

public static boolean deleteFile (File file)

Delete a file.

Parameters
file the file to be deleted
Returns
  • true on success

public static String escapeFileName (String filename)

Escape filename invalid characters with an underscore.

For proper path sanitization, use sanitizePath(String, boolean, boolean).

Parameters
filename to escape
Returns
  • the escaped filename

public static String escapeFileName (String filename, char newChar)

Escape illegal characters in filename by the provided char. Note than this is a black-list escaper (whitelist character would be too costly to manage any char) so file name can still be irrelevant on the target Operating System. The list of excluded characters are ':', '\', '/', '*', '"', '?', '|', '<', '>' which covers most of the invalid characters.

For proper path sanitization, use sanitizePath(String, boolean, boolean).

Parameters
filename to escape
newChar replacement character
Returns
  • the escaped filename

public static String escapeFileNameStrict (String filename, char newChar)

Create a valid filename from any string. Compared to escapeFileName(String, char), this is a white-list escaper so generated filename will be legal on any non-exotic target Operating System. The list of allowed characters are any alphanumeric char, '-', '_', '.', '''.

For proper path sanitization, use sanitizePath(String, boolean, boolean).

Parameters
filename to escape
newChar replacement character
Returns
  • the escaped filename

public static String escapeFileNameStrict (String filename)

Create a valid filename with an underscore for non alphanumeric char, '-', '_', '.' nor '''.

For proper path sanitization, use sanitizePath(String, boolean, boolean).

Parameters
filename to escape
Returns
  • the escaped filename

public static String expandPath (String path)

Perform expansion of certain shell artifacts used in path names.

Currently, the expansions performed are:

  • a leading tilda is expanded to a user's home directory

Returns
  • a full path name, if possible - otherwise, the original path is returned

public static void extractToFolder (File inputZipFile, File outputFolder)

Extract the contents of a zip archive to a target folder.

Parameters
inputZipFile input zip file path
outputFolder output folder directory
Throws
IOException if an error occurred; the current state of extraction within the target folder is not erased

public static String getCwd ()

Get the path of the current working directory.

public static String getExtension (String path)

Extract the extension of a file path.

Parameters
path a path
Returns
  • the extension (always starting with a dot), or the empty string

public static String getExtension (File file)

Extract the extension of a file path.

Parameters
file a file
Returns
  • the extension (always starting with a dot), or the empty string

public static byte getFirstByte (String path)

Get the first byte of a file. This method never throws exceptions. If an error occurs, 0 is returned. It is up to the client to handle that special case.

public static int getFirstIntLE (String path)

Get the first 4-byte of a file, read as a little-endian integer. This method never throws exceptions. If an error occurs, 0 is returned. It is up to the client to handle that special case.

Parameters
path file path
Returns
  • the first int, 0 on error

public static short getFirstShortLE (String path)

Get the first 2-byte of a file, read as a little-endian short. This method never throws exceptions. If an error occurs, 0 is returned. It is up to the client to handle that special case.

public static File getHomeFolder ()

Retrieve the current user's home folder.

public static String getOriginalCwd ()

Get original working directory, i.e. the value of the current directory set by the JVM when the program was started.

This method is unreliable. It assumes that all updates to the current directory are done through this class.

public static File getParentFile2 (File file)

A safer implementation of getParentFile(). If the input file is a single-level relative path (eg, "abc"), this method will first retrieve the absolute path (relative to the current folder) before trying to retrieve the parent folder.

Parameters
file file or folder
Returns
  • null if there is no parent folder, eg in the case of a a root folder

public static String getRelativePath (File file, File base)

Provide the path to a file relative to a base.

Parameters
file a file
base the base to check for
Returns
  • null if `file` is not rooted in `base`; else, the relative path of `file` (relative to `base`)

public static File getSafeTempFolder ()

Retrieve the JEB session specific temp folder in the user's temporary folder. That folder can safely be used to drop temporary files and create additional temporary folder.

public static File getTempFolder ()

Retrieve the temporary folder.

Returns
  • the temp folder, never null

public static boolean inFolder (File file, File folder)

Determine if a hypothetical file would be contained within a hypothetical folder, i.e. whether or not the folder would be an ancestor of the file.

Parameters
file file or folder to test (whose existence is not required)
folder candidate ancestor folder (whose existence is not required)
Returns
  • true if the candidate folder looks like an ancestor folder of the file

public static boolean isFile (String path)

Determine if a path refers to an existing file.

public static boolean isUrl (String s)

Determine whether the provided input string looks like a URL.

public static List<File> listFiles (String folderpath)

Recursively do a directory listing. The list returned is a list of true files (not directories). Refer to the DirectoryEnumerator object for a more powerful file enumerator.

Returns
  • the list of absolute file paths

public static List<File> listFiles (File folder)

Recursively do a directory listing. The list returned is a list of true files (not directories). Refer to the DirectoryEnumerator object for a more powerful file enumerator.

Returns
  • the list of absolute files

public static void mkdirs2 (File dir)

Create a directory and its parents. This method is meant as a replacement for mkdirs() that provides failed creation information.

Parameters
dir folder to be created
Returns
  • true if the directory did not exist and was created; false if the directory existed already
Throws
IOException if the creation failed

public static boolean mkdirs2Ex (File dir)

Create a directory and its parents. Soft failure (false return) if the directory already exists.

Parameters
dir folder to be created
Returns
  • true if the directory did not exist and was created; false if the directory existed already
Throws
IOException if the creation failed

public static String noExtension (String path)

public static File noExtension (File file)

public static List<String> parsePathElements (String s)

Parse the elements of a path.

Parameters
s a path
Returns
  • a list of path elements, possibly empty

public static byte[] readFile (String path)

Read the contents of a binary file.@return

Throws
IOException

public static byte[] readFile (File file, long maxAllowedSize)

Read the contents of a binary file.@return

Parameters
maxAllowedSize specify a maximum read size
Throws
IOException on IO error, or if the read size exceeds

public static byte[] readFile (File file)

Read the contents of a binary files.@return

Throws
IOException

public static byte[] readFileSafe (File file)

Read a binary file safely. If any error happens, an empty array is returned.

Parameters
file input file
Returns
  • the bytes in the file, never null (empty array on error)

public static String readInputLine ()

Read a line from the standard input.@return

Throws
IOException

public static String readInputLineSafe ()

Read a line from the standard input. This method is safe to use; it does not raise, instead returning a null string on error.

public static byte[] readInputStream (InputStream in)

Read and reliably return all bytes of an input stream. The stream must be less than 2Gb. The caller is responsible for closing the input stream after reading.@return

Throws
IOException

public static List<String> readLines (InputStream input)

Read the contents of a stream as a text buffer of UTF-8 encoded strings.@return

Throws
IOException

public static List<String> readLines (File file)

Read the UTF-8 encoded lines of a text file.@return

Throws
IOException

public static List<String> readLines (File file, Charset encoding)

Read the lines of a text file.@return

Throws
IOException

public static List<String> readLines (InputStream input, Charset encoding)

Read the contents of a stream as a line of strings.

Parameters
input the input stream
encoding the stream encoding
Returns
  • a list of strings, without new-line characters
Throws
IOException on IO error

public static List<String> readLinesSafe (File file, Charset encoding)

Read the lines of a text file. On error, the method returns null.

Returns
  • a list of lines without newline chars, null on error

public static List<String> readLinesSafe (File file)

Read the lines of a UTF8 encoded text file. On error, the method returns null.

Returns
  • a list of lines without newline chars, null on error

public static boolean renameFile (File src, File dst, int mode)

Rename a file with options.

Parameters
src source file
dst destination
mode define the mechanics of the renaming operations:
  • 0: standard rename, fail if 'dst' already exists or 'src' does not exist
  • 1: overwrite 'dst' if 'dst' already exists
  • 2: delete 'src' if 'dst' already exists
Returns
  • true on success

public static File replaceExtension (File file, String extension)

Parameters
extension the new extension, eg ".xyz"

public static String sanitizePath (String path, boolean isSinglePathElement, boolean replaceBlankCharacters)

Sanitize a path. The returned path is guaranteed to be legal on the current filesystem (FS) if and only if the element being sanitized is a single path element. For full paths elements, sanitization cannot be guaranteed because some characters which could yield to bad paths, cannot be safely sanitized.

Notes:
- the following characters are always sanitized: ? % * | < > "
- if a single path element is provided, the following characters are sanitized as well: / \ :

Parameters
path a path (absolute or not)
isSinglePathElement true if the provided path should be treated as a single path element, allowing more aggressive replacements
replaceBlankCharacters if true, sanitize all blank characters (per the Unicode definition of a blank character) as well, even though some may be legal
Returns
  • a sanitized path, never null, guaranteed to be valid on the current FS

public static String sanitizePathUnsafe (String path)

Attempt to sanitize a path.

Under some conditions, the returned path may be unsafe, eg on Windows: the sanitization of a path like "x::z" will generate an unsafe path. You must use sanitizePath(String, boolean, boolean) to guarantee sanitization.

public static String setCwd (String cwd)

Set the path of the current working directory.

Note: handle with care, changing the CWD may not impact all subsequent file read and write operations. It is safer to retrieve and use the CWD with getCwd().

Returns
  • previous working directory

public static String simplifyPath (String path)

Simplify a path. This method is OS-dependent. To call a specific (Unix or Windows) version of this method, use simplifyPathUnix(String) or simplifyPathWindows(String).

Rules:
- . and .. uses are resolved.
- Multiple-path separator uses such as /// or \\ are resolved.
- Redundant trailing separators are removed.
- The empty path is always resolved to ..
- If the FS is case-insensitive (e.g. NTFS), the case is not standardized (Windows).
- Symbolic links are not resolved.

Parameters
path input path
Returns
  • absolute simplified path

public static String simplifyPathUnix (String path)

public static String simplifyPathWindows (String path)

public static String[] splitExtension (String path)

Split a file path into its extension-less part and its extension.

Parameters
path a file path
Returns
  • a 2-element string array; the extension, if any, is the second element and always start with '.' unless it's empty

public static String[] splitPath (String path)

Split a path into its base part and its filename part.

Unlike getName(), this method considers both slash and backslash to be valid path separators.

Returns
  • a two-element array: the first element contains the base and may be empty (if non-empty, it will always end by a separator); the second element is the name, which does not contain any separator

public static void writeFile (File file, String str)

Write a string to a file using the default character encoding of the current system. Existing file contents will be overwritten.

Parameters
file destination file
str string
Throws
IOException on error

public static void writeFile (File file, byte[] data, boolean createDirs)

Write data to a file whose containing directory structure may not exist. Existing file contents will be overwritten.

Throws
IOException

public static void writeFile (File file, byte[] data, int offset, int size)

Write data to a file. Existing file contents will be overwritten.

Throws
IOException

public static void writeFile (File file, String str, String charsetName)

Write a string to a file using the given character encoding of the current system. Existing file contents will be overwritten.

Throws
IOException

public static void writeFile (File file, byte[] data, int offset, int size, boolean createDirs)

Write data to a file whose containing directory structure may not exist. Existing file contents will be overwritten.

Parameters
createDirs create the intermediate directories if need be
Throws
IOException

public static void writeFile (File file, byte[] data)

Write data to a file. Existing file contents will be overwritten.

Parameters
file destination file
data binary data to write
Throws
IOException on error

public static boolean writeFileSafe (File file, byte[] data, int offset, int size, boolean createDirs)

Write a binary file safely.

public static boolean writeFileSafe (File file, byte[] data, boolean createDirs)

Write a binary file safely.

public static void writeLines (OutputStream output, List<? extends CharSequence> lines)

Write UTF-8 encoded strings.

Throws
IOException

public static void writeLines (File file, List<? extends CharSequence> lines)

Write UTF-8 encoded strings.

Throws
IOException

public static void writeLines (OutputStream output, List<? extends CharSequence> lines, Charset encoding)

Write strings.

Throws
IOException

public static void writeLines (File file, List<? extends CharSequence> lines, Charset encoding)

Write strings.

Throws
IOException

public static boolean writeLinesSafe (OutputStream output, List<? extends CharSequence> lines)

Write UTF-8 encoded strings. On error, the method returns false.

public static boolean writeLinesSafe (File file, List<? extends CharSequence> lines, Charset encoding)

Write strings. On error, the method returns false.

public static boolean writeLinesSafe (OutputStream output, List<? extends CharSequence> lines, Charset encoding)

Write strings. On error, the method returns false.

public static boolean writeLinesSafe (File file, List<? extends CharSequence> lines)

Write UTF-8 encoded strings. On error, the method returns false.