public class IOUtils
extends java.lang.Object
Constructor and Description |
---|
IOUtils() |
Modifier and Type | Method and Description |
---|---|
static void |
copy(java.io.File src,
java.io.File dest) |
static void |
copyDirectoryContents(java.io.File src,
java.io.File dst)
Copy everything in the source folder to the destination directory.
|
static void |
copyFile(java.io.File fromFile,
java.io.File toFile)
Copy the contents of fromFile to toFile.
|
static void |
copyFolder(java.io.File src,
java.io.File dest)
Copy the contents of a folder into another.
|
static long |
copyStream(java.io.InputStream in,
java.io.OutputStream out)
Copy all of the bytes from one inputstream to another, returning the number of bytes copied.
|
static java.io.File |
createTempFolder() |
static void |
delete(java.io.File file) |
static void |
deleteFile(java.io.File file)
Delete a file immediately.
|
static boolean |
deleteFolder(java.io.File folder)
Delete recursively a directory and all its content.
|
static java.io.File |
getUnusedFileNameWithBaseAndExtension(java.io.File containerFolder,
java.lang.String baseName,
java.lang.String extension)
Return a unique, non-existent file with the given name and name and file extension.
|
static boolean |
isDirectoryEmpty(java.io.File dir)
Returns whether a directory is empty or not.
|
static void |
renameFilesMatching(java.lang.String oldName,
java.lang.String newName,
java.io.File dir)
This method will rename files matching oldName to newName in the given dir
|
static void |
writeAtomically(byte[] dataToWrite,
java.io.File outputFile)
Atomically write the given data to the outputFile.
|
static void |
writeAtomically(java.lang.String stringToWrite,
java.io.File outputFile)
Atomically write the given string to the outputFile in UTF8.
|
static void |
zipRecursively(java.util.zip.ZipOutputStream zipOut,
java.io.File fileToZip,
java.io.FilenameFilter filter)
Recursively zip the given file or directory, only adding files matching the filter (if any).
|
public static java.io.File getUnusedFileNameWithBaseAndExtension(java.io.File containerFolder, java.lang.String baseName, java.lang.String extension)
public static void copy(java.io.File src, java.io.File dest) throws java.io.IOException
java.io.IOException
public static void delete(java.io.File file)
public static long copyStream(java.io.InputStream in, java.io.OutputStream out) throws java.io.IOException
java.io.IOException
public static java.io.File createTempFolder()
public static void copyFile(java.io.File fromFile, java.io.File toFile) throws java.io.IOException
java.io.IOException
public static void copyFolder(java.io.File src, java.io.File dest) throws java.io.IOException
src
- the folder where to copy the files fromdest
- the folder where to copy the file tojava.io.IOException
public static boolean deleteFolder(java.io.File folder)
folder
- the folder to deletepublic static void deleteFile(java.io.File file)
file
- public static void renameFilesMatching(java.lang.String oldName, java.lang.String newName, java.io.File dir)
oldName
- newName
- public static void copyDirectoryContents(java.io.File src, java.io.File dst) throws java.io.IOException
src
- dst
- java.io.IOException
public static void zipRecursively(java.util.zip.ZipOutputStream zipOut, java.io.File fileToZip, java.io.FilenameFilter filter) throws java.io.IOException, java.util.zip.ZipException
java.io.IOException
java.util.zip.ZipException
public static boolean isDirectoryEmpty(java.io.File dir)
dir
- public static void writeAtomically(java.lang.String stringToWrite, java.io.File outputFile) throws java.io.IOException
java.io.IOException
public static void writeAtomically(byte[] dataToWrite, java.io.File outputFile) throws java.io.IOException
java.io.IOException