public class FileUtils extends Object
| Modifier and Type | Class and Description |
|---|---|
static interface |
FileUtils.FileOperation |
static interface |
FileUtils.LineListener |
static class |
FileUtils.MaybeWindowsMemoryMappedFileReleaseProblem |
| Modifier and Type | Field and Description |
|---|---|
static boolean |
OS_IS_WINDOWS |
| Constructor and Description |
|---|
FileUtils() |
| Modifier and Type | Method and Description |
|---|---|
static void |
copyFile(File srcFile,
File dstFile) |
static void |
copyRecursively(File fromDirectory,
File toDirectory) |
static void |
copyRecursively(File fromDirectory,
File toDirectory,
FileFilter filter) |
static boolean |
deleteFile(File file) |
static void |
deleteRecursively(File directory) |
static long |
directorySize(File directory)
Gives the recursive size of all files in a directory.
|
static FileUtils.LineListener |
echo(PrintStream target) |
static String |
fixSeparatorsInPath(String path) |
static File |
getMostCanonicalFile(File file) |
static void |
moveDirectoryContents(File baseDir,
File targetDir)
Move the contents of one directory into another directory.
|
static void |
moveFile(File toMove,
File target)
Utility method that moves a file from its current location to the
new target location.
|
static File |
moveFileToDirectory(File toMove,
File targetDirectory)
Utility method that moves a file from its current location to the
provided target directory.
|
static BufferedReader |
newBufferedFileReader(File file,
Charset charset) |
static PrintWriter |
newFilePrintWriter(File file,
Charset charset) |
static File |
path(File root,
String... path) |
static File |
path(String root,
String... path) |
static String |
readTextFile(File file,
Charset charset) |
static void |
readTextFile(File file,
FileUtils.LineListener listener) |
static String |
relativePath(File baseDir,
File storeFile)
Given a directory and a path under it, return filename of the path
relative to the directory.
|
static boolean |
renameFile(File srcFile,
File renameToFile) |
static void |
truncateFile(File file,
long position) |
static void |
truncateFile(SeekableByteChannel fileChannel,
long position) |
static void |
windowsSafeIOOperation(FileUtils.FileOperation operation) |
static void |
writeToFile(File target,
String text,
boolean append) |
public static void deleteRecursively(File directory) throws IOException
IOExceptionpublic static boolean deleteFile(File file)
public static void moveFile(File toMove, File target) throws IOException
renameFile(File, File) instead.toMove - The File object to move.target - Target file to move to.IOExceptionpublic static File moveFileToDirectory(File toMove, File targetDirectory) throws IOException
renameFile(File, File) instead.toMove - The File object to move.targetDirectory - the destination directoryIOExceptionpublic static boolean renameFile(File srcFile, File renameToFile) throws IOException
IOExceptionpublic static void truncateFile(SeekableByteChannel fileChannel, long position) throws IOException
IOExceptionpublic static void truncateFile(File file, long position) throws IOException
IOExceptionpublic static void copyFile(File srcFile, File dstFile) throws IOException
IOExceptionpublic static void copyRecursively(File fromDirectory, File toDirectory) throws IOException
IOExceptionpublic static void copyRecursively(File fromDirectory, File toDirectory, FileFilter filter) throws IOException
IOExceptionpublic static void writeToFile(File target, String text, boolean append) throws IOException
IOExceptionpublic static BufferedReader newBufferedFileReader(File file, Charset charset) throws FileNotFoundException
FileNotFoundExceptionpublic static PrintWriter newFilePrintWriter(File file, Charset charset) throws FileNotFoundException
FileNotFoundExceptionpublic static void windowsSafeIOOperation(FileUtils.FileOperation operation) throws IOException
IOExceptionpublic static void moveDirectoryContents(File baseDir, File targetDir) throws IOException
IOExceptionpublic static long directorySize(File directory)
public static FileUtils.LineListener echo(PrintStream target)
public static void readTextFile(File file, FileUtils.LineListener listener) throws IOException
IOExceptionpublic static String readTextFile(File file, Charset charset) throws IOException
IOExceptionpublic static String relativePath(File baseDir, File storeFile) throws IOException
baseDir - The base directory, containing the storeFilestoreFile - The store file path, must be contained under
baseDirstoreFile to
baseDirIOException - As per File.getCanonicalPath()Copyright © 2002–2015 The Neo4j Graph Database Project. All rights reserved.