public class FileUtils extends Object
| Modifier and Type | Class and Description |
|---|---|
static interface |
FileUtils.FileOperation |
static interface |
FileUtils.LineListener |
static class |
FileUtils.MaybeWindowsMemoryMappedFileReleaseProblem |
| Constructor and Description |
|---|
FileUtils() |
| Modifier and Type | Method and Description |
|---|---|
static OpenOption[] |
convertOpenMode(String mode) |
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 |
deletePathRecursively(Path path) |
static void |
deleteRecursively(File directory) |
static FileUtils.LineListener |
echo(PrintStream target) |
static String |
fixSeparatorsInPath(String path) |
static File |
getMostCanonicalFile(File file) |
static boolean |
isEmptyDirectory(File directory)
Check if directory is empty.
|
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 FileChannel |
open(Path path,
String mode) |
static InputStream |
openAsInputStream(Path path) |
static OutputStream |
openAsOutputStream(Path path,
boolean append) |
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 |
writeAll(FileChannel channel,
ByteBuffer src) |
static void |
writeAll(FileChannel channel,
ByteBuffer src,
long position) |
static void |
writeToFile(File target,
String text,
boolean append) |
public static void deleteRecursively(File directory) throws IOException
IOExceptionpublic static void deletePathRecursively(Path path) 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 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()public static void writeAll(FileChannel channel, ByteBuffer src, long position) throws IOException
IOExceptionpublic static void writeAll(FileChannel channel, ByteBuffer src) throws IOException
IOExceptionpublic static OpenOption[] convertOpenMode(String mode)
public static FileChannel open(Path path, String mode) throws IOException
IOExceptionpublic static InputStream openAsInputStream(Path path) throws IOException
IOExceptionpublic static boolean isEmptyDirectory(File directory) throws IOException
directory - - directory to checkIllegalArgumentException - if specified directory represent a fileIOException - if some problem encountered during reading directory contentpublic static OutputStream openAsOutputStream(Path path, boolean append) throws IOException
IOExceptionCopyright © 2002–2016 The Neo4j Graph Database Project. All rights reserved.