public final class FileHelper extends Object
| Constructor and Description |
|---|
FileHelper() |
| Modifier and Type | Method and Description |
|---|---|
static long |
copy(File input,
File output)
Copies one file to another using
copy(InputStream, OutputStream). |
static long |
copy(File input,
File output,
byte[] copyBuffer)
Copies one file to another using the supplied buffer.
|
static long |
copy(InputStream in,
File outputFile)
Copies an
InputStream to a file using copy(InputStream, OutputStream). |
static long |
copy(InputStream in,
OutputStream out)
Copies an
InputStream to an OutputStream using a local internal buffer for performance. |
static long |
copy(InputStream in,
OutputStream out,
byte[] copyBuffer)
Copies an
InputStream to an OutputStream using the specified buffer. |
static void |
copyRec(File source,
File target)
Copies one directory or file to another.
|
static boolean |
createFile(String path)
Creates a file specified by a path.
|
static boolean |
deleteFile(String path)
Deletes a file specified by a path.
|
static boolean |
fileExists(String path)
Checks if a file specified by a path exits.
|
static long |
globalBufferCopy(InputStream in,
OutputStream out)
Copies an
InputStream to an OutputStream using a global internal buffer for performance. |
static void |
moveRec(File source,
File target)
Moves one directory or file to another.
|
static void |
removeRec(File toRemove)
Removes a file.
|
public FileHelper()
public static boolean deleteFile(String path)
path - path of file to be deletedtrue if file has been deleted, false otherwisepublic static boolean fileExists(String path)
path - path of file to be checkedtrue if file exists, false otherwisepublic static boolean createFile(String path) throws IOException
path - path of file to be createdtrue if file has been created, false if the file already existsIOException - If an I/O error occurredpublic static void removeRec(File toRemove)
toRemove - file to be removedpublic static void moveRec(File source, File target) throws IOException
source - file to move fromtarget - file to move toIOException - if an I/O error occurs (may result in partially done work)public static void copyRec(File source, File target) throws IOException
source - directory or file to copy fromtarget - directory or file to copy toIOException - if an I/O error occurs (may result in partially done work)public static long copy(File input, File output) throws IOException
copy(InputStream, OutputStream).input - source fileoutput - destination fileIOException - if an I/O error occurs (may result in partially done work)copy(InputStream, OutputStream)public static long copy(File input, File output, byte[] copyBuffer) throws IOException
input - source fileoutput - destination filecopyBuffer - buffer used for copyingIOException - if an I/O error occurs (may result in partially done work)copy(InputStream, OutputStream)public static long copy(InputStream in, File outputFile) throws IOException
InputStream to a file using copy(InputStream, OutputStream).in - stream to copy fromoutputFile - file to copy toIOException - if an I/O error occurs (may result in partially done work)copy(InputStream, OutputStream)public static long copy(InputStream in, OutputStream out) throws IOException
InputStream to an OutputStream using a local internal buffer for performance.
Compared to globalBufferCopy(InputStream, OutputStream) this method allows for better
concurrency, but each time it is called generates a buffer which will be garbage.in - stream to copy fromout - stream to copy toIOException - if an I/O error occurs (may result in partially done work)globalBufferCopy(InputStream, OutputStream)public static long globalBufferCopy(InputStream in, OutputStream out) throws IOException
InputStream to an OutputStream using a global internal buffer for performance.
Compared to copy(InputStream, OutputStream) this method generated no garbage,
but decreases concurrency.in - stream to copy fromout - stream to copy toIOException - if an I/O error occurs (may result in partially done work)copy(InputStream, OutputStream)public static long copy(InputStream in, OutputStream out, byte[] copyBuffer) throws IOException
InputStream to an OutputStream using the specified buffer.in - stream to copy fromout - stream to copy tocopyBuffer - buffer used for copyingIOException - if an I/O error occurs (may result in partially done work)globalBufferCopy(InputStream, OutputStream),
copy(InputStream, OutputStream)Copyright © 2004-2013 The Apache Software Foundation. All Rights Reserved.