public class FileUtils extends Object
| Modifier and Type | Field and Description |
|---|---|
static String |
JAVA_IO_TMPDIR |
| Modifier and Type | Method and Description |
|---|---|
static long |
calcAdlerChecksum(File f,
String encoding) |
int |
compareLastModified(long date,
File file)
Compares a given date with the last modified date of a file, taking
into account the filesystem resolution for file dates available on the
current platform.
|
static File |
createEmptyDir(File parent,
String name) |
static File |
createTempDir(String name) |
static File |
createTempDir(String name,
File parent) |
static boolean |
deltree(File rootDir)
delete a file, or directory and all of its contents
|
static void |
dirCopy(File srcDir,
File destDir,
boolean deleteDestDir)
Copies the whole content (files and subdirectories) from
|
static void |
fileCopy(File src,
File dest) |
static String |
fromURI(String uri)
*** stolen from Apache Ant 1.6
Constructs a file path from a
file: URI. |
static File |
getCurrentDirIfNull(File dir) |
static FileUtils |
getInstance() |
static File |
getJavaTempDir()
Returns system's temporary directory as defined in java.io.tmpdir
|
static String |
getNormalizedPath(String inputPath)
Converts all backslashes to forward-slashes, so that Unix-style file separator is used.
|
long |
getPlatformFSResolution() |
static String |
getPlatformSpecificPath(String inputPath)
Converts all forward-slashes and back-slashes to a platform-specific file separator
(i.e.
|
static String |
getRelativePath(File a,
File b) |
static String |
getRelativePath(File a,
File b,
String pathSep) |
static String |
getRelativePath(String a,
String b) |
static String |
getRelativePath(String a,
String b,
String pathSep) |
static void |
inputStreamToFile(InputStream in,
File outFile)
Read data from input stream
in and write to outFile file. |
static boolean |
isAncestorOf(File a,
File b) |
static File[] |
listMatchingFilesForDir(File dir,
String regex)
Lists only the files, not the directories for a given directory.
|
static String |
readChars(DataInputStream in) |
static void |
readerCopy(Reader src,
Writer dest) |
static void |
resourceToFile(ClassLoader classLoader,
String resourcePath,
File outputFile)
Copy
resourcePath resource using classLoader to outputFile. |
static void |
streamCopy(InputStream inputStream,
OutputStream outputStream) |
public static final String JAVA_IO_TMPDIR
public static FileUtils getInstance()
public static File getJavaTempDir()
RuntimeException - if java.io.tmpdir is not setpublic long getPlatformFSResolution()
public static void readerCopy(Reader src, Writer dest) throws IOException
IOExceptionpublic static void fileCopy(File src, File dest) throws IOException
IOExceptionpublic static void dirCopy(File srcDir, File destDir, boolean deleteDestDir) throws IOException
srcDirto
destDirpreserving directory layout. If
deleteDestDiris set to true, destination directory will be deleted if exists. Otherwise files/subdirectories from source directory will be added to existing target directory (possibly overwriting existing files). Note that timestamps are not preserved.
IOExceptionpublic static void inputStreamToFile(@NotNull
InputStream in,
@NotNull
File outFile)
throws IOException
in and write to outFile file.in - sourceoutFile - targetIOExceptionpublic static void streamCopy(InputStream inputStream, OutputStream outputStream) throws IOException
IOExceptionpublic static void resourceToFile(ClassLoader classLoader, String resourcePath, File outputFile) throws IOException
resourcePath resource using classLoader to outputFile.IOExceptionpublic static boolean deltree(File rootDir)
rootDir - the file or directory to start atpublic static String getNormalizedPath(String inputPath)
public static String getPlatformSpecificPath(String inputPath)
public static long calcAdlerChecksum(File f, String encoding) throws IOException
IOExceptionpublic static String fromURI(String uri)
file: URI.
Will be an absolute path if the given URI is absolute.
Swallows '%' that are not followed by two characters, doesn't deal with non-ASCII characters.
uri - the URI designating a file in the local filesystem.public int compareLastModified(long date,
File file)
public static File[] listMatchingFilesForDir(File dir, String regex) throws IOException
dir - the dir to list files ofregex - filenames must match thisIOException - if the dir cannot be readpublic static File createTempDir(String name) throws IOException
IOExceptionpublic static File createTempDir(String name, File parent) throws IOException
IOExceptionpublic static String readChars(DataInputStream in) throws IOException
IOExceptionCopyright © 2024 OpenClover.org. All rights reserved.