|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.commons.transaction.util.FileHelper
public final class FileHelper
Helper methods for file manipulation. All methods are thread safe.
Constructor Summary | |
---|---|
FileHelper()
|
Method Summary | |
---|---|
static long |
copy(java.io.File input,
java.io.File output)
Copies one file to another using copy(InputStream, OutputStream) . |
static long |
copy(java.io.File input,
java.io.File output,
byte[] copyBuffer)
Copies one file to another using the supplied buffer. |
static long |
copy(java.io.InputStream in,
java.io.File outputFile)
Copies an InputStream to a file using copy(InputStream, OutputStream) . |
static long |
copy(java.io.InputStream in,
java.io.OutputStream out)
Copies an InputStream to an OutputStream using a local internal buffer for performance. |
static long |
copy(java.io.InputStream in,
java.io.OutputStream out,
byte[] copyBuffer)
Copies an InputStream to an OutputStream using the specified buffer. |
static void |
copyRec(java.io.File source,
java.io.File target)
Copies one directory or file to another. |
static boolean |
createFile(java.lang.String path)
Creates a file specified by a path. |
static boolean |
deleteFile(java.lang.String path)
Deletes a file specified by a path. |
static boolean |
fileExists(java.lang.String path)
Checks if a file specified by a path exits. |
static long |
globalBufferCopy(java.io.InputStream in,
java.io.OutputStream out)
Copies an InputStream to an OutputStream using a global internal buffer for performance. |
static void |
moveRec(java.io.File source,
java.io.File target)
Moves one directory or file to another. |
static void |
removeRec(java.io.File toRemove)
Removes a file. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public FileHelper()
Method Detail |
---|
public static boolean deleteFile(java.lang.String path)
path
- path of file to be deleted
true
if file has been deleted, false
otherwisepublic static boolean fileExists(java.lang.String path)
path
- path of file to be checked
true
if file exists, false
otherwisepublic static boolean createFile(java.lang.String path) throws java.io.IOException
path
- path of file to be created
true
if file has been created, false
if the file already exists
java.io.IOException
- If an I/O error occurredpublic static void removeRec(java.io.File toRemove)
toRemove
- file to be removedpublic static void moveRec(java.io.File source, java.io.File target) throws java.io.IOException
source
- file to move fromtarget
- file to move to
java.io.IOException
- if an I/O error occurs (may result in partially done work)public static void copyRec(java.io.File source, java.io.File target) throws java.io.IOException
source
- directory or file to copy fromtarget
- directory or file to copy to
java.io.IOException
- if an I/O error occurs (may result in partially done work)public static long copy(java.io.File input, java.io.File output) throws java.io.IOException
copy(InputStream, OutputStream)
.
input
- source fileoutput
- destination file
java.io.IOException
- if an I/O error occurs (may result in partially done work)copy(InputStream, OutputStream)
public static long copy(java.io.File input, java.io.File output, byte[] copyBuffer) throws java.io.IOException
input
- source fileoutput
- destination filecopyBuffer
- buffer used for copying
java.io.IOException
- if an I/O error occurs (may result in partially done work)copy(InputStream, OutputStream)
public static long copy(java.io.InputStream in, java.io.File outputFile) throws java.io.IOException
InputStream
to a file using copy(InputStream, OutputStream)
.
in
- stream to copy fromoutputFile
- file to copy to
java.io.IOException
- if an I/O error occurs (may result in partially done work)copy(InputStream, OutputStream)
public static long copy(java.io.InputStream in, java.io.OutputStream out) throws java.io.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 to
java.io.IOException
- if an I/O error occurs (may result in partially done work)globalBufferCopy(InputStream, OutputStream)
public static long globalBufferCopy(java.io.InputStream in, java.io.OutputStream out) throws java.io.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 to
java.io.IOException
- if an I/O error occurs (may result in partially done work)copy(InputStream, OutputStream)
public static long copy(java.io.InputStream in, java.io.OutputStream out, byte[] copyBuffer) throws java.io.IOException
InputStream
to an OutputStream
using the specified buffer.
in
- stream to copy fromout
- stream to copy tocopyBuffer
- buffer used for copying
java.io.IOException
- if an I/O error occurs (may result in partially done work)globalBufferCopy(InputStream, OutputStream)
,
copy(InputStream, OutputStream)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |