Modifier and Type | Method and Description |
---|---|
static void |
convertLineSeparators(File sourceFile,
File destinationFile)
Converts the line separators in the supplied sourceFile to line
separators used by the platform that executes this code.
|
static void |
copy(File sourceFile,
File destinationFile)
Copies the supplied sourceFile to the supplied destinationFile.
|
static String |
createFilePath(String inputPath,
String inputFile)
Creates a complete path to a file from the supplied path and file.
|
static String |
readEncodedText(File file,
Charset characterSet)
Reads the supplied file with the supplied characterSet from start to
finish.
|
static String |
readText(File file)
Reads the text from the supplied file from start to finish.
|
public static String readText(File file) throws IOException
file
- The file to read.FileNotFoundException
- When the supplied file does not
exist.IOException
- When the supplied file could not be read. This could
also occur during reading of the supplied file.NullPointerException
- When the supplied file is null.public static String readEncodedText(File file, Charset characterSet) throws IOException
file
- The file to read.characterSet
- The character set to use for the encoding.
FileNotFoundException
- When the supplied file does not
exist.IOException
- When the supplied file could not be read. This could
also occur during reading of the supplied file.NullPointerException
- When the supplied file is null.public static void convertLineSeparators(File sourceFile, File destinationFile) throws IOException
sourceFile
- The file to convert.destinationFile
- The file that will contain the converted
sourceFile.FileNotFoundException
- When the supplied sourtceFile does
not exist.IOException
- When reading from the supplied sourceFile or writing
to the supplied destinationFile or when the supplied destinationFile
would overwrite the supplied sourceFile.NullPointerException
- When either the supplied sourceFile or
destinationFile is null.public static void copy(File sourceFile, File destinationFile) throws IOException
CFile.copy(new File("/temp/input.txt"),new File("/temp/input.txt.copy"));
sourceFile
- The file to copy.destinationFile
- The file that will contain the copy of the
supplied sourceFile.FileNotFoundException
- When the supplied sourceFile does
not exist or is a directory.IOException
- When an IO error occurs during the copy.NullPointerException
- When either the supplied sourceFile or
destinationFile is null.public static String createFilePath(String inputPath, String inputFile)
inputPath
- Path to the file. A null path or an empty path implies
the current directory. Spaces are trimmed from both sides!inputFile
- File name.
IllegalArgumentException
- When the supplied inputFile is empty or a
forward slash.NullPointerException
- When the supplied inputFile is null.Copyright © 2008–2018. All rights reserved.