Modifier and Type | Method and Description |
---|---|
static boolean |
deletePath(File path)
Delete the specified path, recursively if this is a directory.
|
static boolean |
deletePath(File path,
boolean childrenOnly)
Delete the specified path, recursively if this is a directory.
|
static String |
getDecodedURLFromFilePath(File path)
Transform a file path into a URL in non URL-ncoded form.
|
static byte[] |
getFileAsByte(File file)
Get the content of a file as an array of bytes.
|
static byte[] |
getFileAsByte(String path)
Get the content of a file as an array of bytes.
|
static String |
getFileExtension(File file)
Get the extension of a file.
|
static InputStream |
getFileInputStream(File path)
Get an input stream given a file.
|
static InputStream |
getFileInputStream(String path)
Get an input stream given a file path.
|
static String |
getFileName(String filePath)
Get the name of a file from its full path.
|
static OutputStream |
getFileOutputStream(File file)
Get an output stream given a file path.
|
static OutputStream |
getFileOutputStream(String path)
Get an output stream given a file path.
|
static List<String> |
getFilePathList(String fileListPath)
Get a list of files whose paths are found in a text file.
|
static Reader |
getFileReader(String path)
Get a
Reader for the specified file path, looked up first in the file system then in the classpath. |
static Writer |
getFileWriter(String path)
Get a
Writer for the specified file path. |
static File |
getJPPFTempDir() |
static String |
getParentFolder(String filePath)
Get the parent folder of a file or directory from its full path.
|
static byte[] |
getPathAsByte(String path)
Get the content of a file or resource on the classpath as an array of bytes.
|
static URL |
getURLFromFilePath(File path)
Transform a file path into a URL.
|
static URL |
getURLFromFilePath(String path)
Transform a file path into a URL.
|
static void |
main(String... args)
Entry point for the splitTextFile() method.
|
static void |
mkdirs(File file)
Create the folders of the specified path, if they do not all already esist.
|
static String |
readTextFile(File file)
Read the content of a specified file into a string.
|
static String |
readTextFile(Reader aReader)
Read the content of a specified reader into a string.
|
static String |
readTextFile(String filename)
Read the content of a specified file into a string.
|
static void |
splitTextFile(String file,
int splitSize)
Split a file into multiple files whose size is as close as possible to the specified split size.
|
static List<String> |
textFileAsLines(Reader aReader)
Read the content of a specified reader into a string.
|
static File[] |
toFiles(File dir,
String... names)
Convert a set of file names into a set of
File objects. |
static URL[] |
toURLs(File... files)
Convert a set of file paths into a set of URLs.
|
static void |
writeBytesToFile(byte[] data,
File path)
Write a byte array into an file.
|
static void |
writeBytesToFile(byte[] data,
String path)
Write a byte array into an file.
|
static void |
writeBytesToStream(byte[] data,
OutputStream os)
Write a byte array into an output stream.
|
static void |
writeTextFile(File file,
String content)
Write the content of a string into a specified file.
|
static void |
writeTextFile(String filename,
String content)
Write the content of a string into a specified file.
|
static void |
writeTextFile(Writer dest,
String content)
Write the content of a string into a specified file.
|
public static String readTextFile(Reader aReader) throws IOException
aReader
- the reader to read the content from.IOException
- if the file can't be found or read.public static List<String> textFileAsLines(Reader aReader) throws IOException
aReader
- the reader to read the content from.IOException
- if the file can't be found or read.public static String readTextFile(File file) throws IOException
file
- the file to read.IOException
- if the file can't be found or read.public static String readTextFile(String filename) throws IOException
filename
- the location of the file to read.IOException
- if the file can't be found or read.public static void writeTextFile(String filename, String content) throws IOException
filename
- the location of the file to write to.content
- the content to write into the file.IOException
- if the file can't be found or read.public static void writeTextFile(File file, String content) throws IOException
file
- the location of the file to write to.content
- the content to write into the file.IOException
- if the file can't be found or read.public static void writeTextFile(Writer dest, String content) throws IOException
dest
- the file to write to.content
- the content to write into the file.IOException
- if the file can't be found or read.public static InputStream getFileInputStream(File path) throws IOException
path
- the file to lookup.InputStream
instance, or null if the file could not be created.IOException
- if an I/O error occurs.public static InputStream getFileInputStream(String path) throws IOException
path
- the path to the file to lookup.InputStream
instance, or null if the file could not be found.IOException
- if an IO error occurs while looking up the file.public static OutputStream getFileOutputStream(String path) throws IOException
path
- the path to the file to lookup.OutputStream
instance, or null if the file could not be created.IOException
- if an IO error occurs while looking up the file.public static OutputStream getFileOutputStream(File file) throws IOException
file
- the file to lookup.OutputStream
instance, or null if the file could not be created.IOException
- if an IO error occurs while looking up the file.public static Reader getFileReader(String path) throws IOException
Reader
for the specified file path, looked up first in the file system then in the classpath.path
- the path to the file to lookup.Reader
instance, or null if the file could not be found.IOException
- if an IO error occurs while looking up the file.public static Writer getFileWriter(String path) throws IOException
Writer
for the specified file path.path
- the path to the file to create or open.Writer
instance.IOException
- if an IO error occurs while creating the file writer.public static List<String> getFilePathList(String fileListPath) throws IOException
fileListPath
- the path to the file that holds the list of documents to validate.IOException
- if an error occurs while looking up or reading the file.public static String getFileExtension(File file)
file
- the file from which to get the extension.public static String getFileName(String filePath)
filePath
- the file from which to get the file name.public static String getParentFolder(String filePath)
filePath
- the path from which to get the parent path.public static void splitTextFile(String file, int splitSize) throws IOException
file
- the text file to split.splitSize
- the maximum number of lines of each resulting file.IOException
- if an IO error occurs.public static void main(String... args)
args
- contains the arguments for the splitTextFile() method.public static byte[] getPathAsByte(String path) throws IOException
path
- the path of the file to read from as a string.IOException
- if an IO error occurs.public static byte[] getFileAsByte(String path) throws IOException
path
- the path of the file to read from as a string.IOException
- if an IO error occurs.public static byte[] getFileAsByte(File file) throws IOException
file
- the abstract path of the file to read from.IOException
- if an IO error occurs.public static File[] toFiles(File dir, String... names)
File
objects.dir
- the directory in which the files are locatednames
- the name part of each file (not the full path)File
objects.public static URL[] toURLs(File... files)
files
- the files whose path is to be converted to a URL.URL
objects.public static void writeBytesToStream(byte[] data, OutputStream os) throws IOException
data
- the byte array to write.os
- the output stream to write to.IOException
- if an I/O error occurs.public static void writeBytesToFile(byte[] data, String path) throws IOException
data
- the byte array to write.path
- the path to the file to write to.IOException
- if an I/O error occurs.public static void writeBytesToFile(byte[] data, File path) throws IOException
data
- the byte array to write.path
- the path to the file to write to.IOException
- if an I/O error occurs.public static boolean deletePath(File path)
path
- the path to delete.public static boolean deletePath(File path, boolean childrenOnly)
path
- the path to delete.childrenOnly
- when true
only delete the children of the specified path, if it is a directory.public static void mkdirs(File file) throws IOException
file
- the path for which to create the folders. If it is a file, then folders for its parent path are created.IOException
- if the folders could not be created.public static URL getURLFromFilePath(String path)
path
- the path to transform.public static URL getURLFromFilePath(File path)
path
- the path to transform.public static String getDecodedURLFromFilePath(File path)
path
- the path to transform.public static File getJPPFTempDir()
Copyright © 2005-2016 JPPF Team.