Modifier and Type | Class and Description |
---|---|
static interface |
FileUtilRt.RepeatableIOOperation<T,E extends java.lang.Throwable> |
protected static interface |
FileUtilRt.SymlinkResolver |
Modifier and Type | Field and Description |
---|---|
static java.io.FileFilter |
ALL_DIRECTORIES |
static java.io.FileFilter |
ALL_FILES |
protected static java.lang.ThreadLocal<byte[]> |
BUFFER |
static int |
LARGE_FILE_PREVIEW_SIZE |
static int |
LARGE_FOR_CONTENT_LOADING |
static int |
MEGABYTE |
static int |
THREAD_LOCAL_BUFFER_LENGTH |
Constructor and Description |
---|
FileUtilRt() |
Modifier and Type | Method and Description |
---|---|
static void |
copy(java.io.File fromFile,
java.io.File toFile) |
static void |
copy(java.io.InputStream inputStream,
java.io.OutputStream outputStream) |
static boolean |
createDirectory(java.io.File path) |
static boolean |
createIfNotExists(java.io.File file) |
static boolean |
createParentDirs(java.io.File file) |
static java.io.File |
createTempDirectory(java.io.File dir,
java.lang.String prefix,
java.lang.String suffix) |
static java.io.File |
createTempDirectory(java.io.File dir,
java.lang.String prefix,
java.lang.String suffix,
boolean deleteOnExit) |
static java.io.File |
createTempDirectory(java.lang.String prefix,
java.lang.String suffix) |
static java.io.File |
createTempDirectory(java.lang.String prefix,
java.lang.String suffix,
boolean deleteOnExit) |
static java.io.File |
createTempFile(java.io.File dir,
java.lang.String prefix,
java.lang.String suffix) |
static java.io.File |
createTempFile(java.io.File dir,
java.lang.String prefix,
java.lang.String suffix,
boolean create) |
static java.io.File |
createTempFile(java.io.File dir,
java.lang.String prefix,
java.lang.String suffix,
boolean create,
boolean deleteOnExit) |
static java.io.File |
createTempFile(java.lang.String prefix,
java.lang.String suffix) |
static java.io.File |
createTempFile(java.lang.String prefix,
java.lang.String suffix,
boolean deleteOnExit) |
static boolean |
delete(java.io.File file)
IMPORTANT: the method is not symlinks- or junction-aware when invoked on Java 6 or earlier.
|
protected static boolean |
deleteFile(java.io.File file) |
static <T,E extends java.lang.Throwable> |
doIOOperation(FileUtilRt.RepeatableIOOperation<T,E> ioTask) |
static boolean |
ensureCanCreateFile(java.io.File file) |
static boolean |
extensionEquals(java.lang.String filePath,
java.lang.String extension) |
static java.io.File |
generateRandomTemporaryPath() |
static java.lang.CharSequence |
getExtension(java.lang.CharSequence fileName) |
static java.lang.CharSequence |
getExtension(java.lang.CharSequence fileName,
java.lang.String defaultValue) |
static java.lang.String |
getExtension(java.lang.String fileName) |
static java.lang.CharSequence |
getNameWithoutExtension(java.lang.CharSequence name) |
static java.lang.String |
getNameWithoutExtension(java.lang.String name) |
static java.io.File |
getParentFile(java.io.File file)
Get parent for the file.
|
static java.lang.String |
getRelativePath(java.io.File base,
java.io.File file)
Gets the relative path from the
base to the file regardless existence or the type of the base . |
static java.lang.String |
getRelativePath(java.lang.String basePath,
java.lang.String filePath,
char separator) |
static java.lang.String |
getRelativePath(java.lang.String basePath,
java.lang.String filePath,
char separator,
boolean caseSensitive) |
static java.lang.String |
getTempDirectory() |
static byte[] |
getThreadLocalBuffer() |
static int |
getUserContentLoadLimit() |
static int |
getUserFileSizeLimit() |
static boolean |
isJarOrZip(java.io.File file) |
static boolean |
isJarOrZip(java.io.File file,
boolean isCheckIsDirectory) |
static boolean |
isTooLarge(long len) |
static byte[] |
loadBytes(java.io.InputStream stream) |
static byte[] |
loadBytes(java.io.InputStream stream,
int length) |
static java.lang.String |
loadFile(java.io.File file) |
static java.lang.String |
loadFile(java.io.File file,
boolean convertLineSeparators) |
static java.lang.String |
loadFile(java.io.File file,
java.lang.String encoding) |
static java.lang.String |
loadFile(java.io.File file,
java.lang.String encoding,
boolean convertLineSeparators) |
static char[] |
loadFileText(java.io.File file) |
static char[] |
loadFileText(java.io.File file,
java.nio.charset.Charset encoding) |
static char[] |
loadFileText(java.io.File file,
java.lang.String encoding) |
static java.util.List<java.lang.String> |
loadLines(java.io.BufferedReader reader) |
static java.util.List<java.lang.String> |
loadLines(java.io.File file) |
static java.util.List<java.lang.String> |
loadLines(java.io.File file,
java.lang.String encoding) |
static java.util.List<java.lang.String> |
loadLines(java.lang.String path) |
static java.util.List<java.lang.String> |
loadLines(java.lang.String path,
java.lang.String encoding) |
static char[] |
loadText(java.io.Reader reader,
int length) |
static void |
setExecutableAttribute(java.lang.String path,
boolean executableFlag)
Deprecated.
not needed in 'util-rt'; use
FileUtil or File methods; for removal in IDEA 2020 |
static java.lang.String |
toCanonicalPath(java.lang.String path,
char separatorChar,
boolean removeLastSlash)
Converts given path to canonical representation by eliminating '.'s, traversing '..'s, and omitting duplicate separators.
|
protected static java.lang.String |
toCanonicalPath(java.lang.String path,
char separatorChar,
boolean removeLastSlash,
FileUtilRt.SymlinkResolver resolver) |
static java.lang.String |
toSystemDependentName(java.lang.String fileName) |
static java.lang.String |
toSystemDependentName(java.lang.String fileName,
char separatorChar) |
static java.lang.String |
toSystemIndependentName(java.lang.String fileName) |
public static final int MEGABYTE
public static final int LARGE_FOR_CONTENT_LOADING
public static final int LARGE_FILE_PREVIEW_SIZE
public static final java.io.FileFilter ALL_FILES
public static final java.io.FileFilter ALL_DIRECTORIES
public static final int THREAD_LOCAL_BUFFER_LENGTH
protected static final java.lang.ThreadLocal<byte[]> BUFFER
public static boolean isJarOrZip(java.io.File file)
public static boolean isJarOrZip(java.io.File file, boolean isCheckIsDirectory)
public static java.lang.String toCanonicalPath(java.lang.String path, char separatorChar, boolean removeLastSlash)
File.getCanonicalPath()
will return), so if the path may contain symlinks,
consider using FileUtil.toCanonicalPath(String, boolean)
instead.protected static java.lang.String toCanonicalPath(java.lang.String path, char separatorChar, boolean removeLastSlash, FileUtilRt.SymlinkResolver resolver)
public static java.lang.String getExtension(java.lang.String fileName)
public static java.lang.CharSequence getExtension(java.lang.CharSequence fileName)
public static java.lang.CharSequence getExtension(java.lang.CharSequence fileName, java.lang.String defaultValue)
public static boolean extensionEquals(java.lang.String filePath, java.lang.String extension)
public static java.lang.String toSystemDependentName(java.lang.String fileName)
public static java.lang.String toSystemDependentName(java.lang.String fileName, char separatorChar)
public static java.lang.String toSystemIndependentName(java.lang.String fileName)
public static java.lang.String getRelativePath(java.io.File base, java.io.File file)
Gets the relative path from the base
to the file
regardless existence or the type of the base
.
NOTE: if a file (not a directory) is passed as the base
, the result cannot be used as a relative path
from the base
parent directory to the file
.
base
- the basefile
- the filebase
to the file
, or null
public static java.lang.String getRelativePath(java.lang.String basePath, java.lang.String filePath, char separator)
public static java.lang.String getRelativePath(java.lang.String basePath, java.lang.String filePath, char separator, boolean caseSensitive)
public static java.lang.CharSequence getNameWithoutExtension(java.lang.CharSequence name)
public static java.lang.String getNameWithoutExtension(java.lang.String name)
public static java.io.File createTempDirectory(java.lang.String prefix, java.lang.String suffix) throws java.io.IOException
java.io.IOException
public static java.io.File createTempDirectory(java.lang.String prefix, java.lang.String suffix, boolean deleteOnExit) throws java.io.IOException
java.io.IOException
public static java.io.File createTempDirectory(java.io.File dir, java.lang.String prefix, java.lang.String suffix) throws java.io.IOException
java.io.IOException
public static java.io.File createTempDirectory(java.io.File dir, java.lang.String prefix, java.lang.String suffix, boolean deleteOnExit) throws java.io.IOException
java.io.IOException
public static java.io.File createTempFile(java.lang.String prefix, java.lang.String suffix) throws java.io.IOException
java.io.IOException
public static java.io.File createTempFile(java.lang.String prefix, java.lang.String suffix, boolean deleteOnExit) throws java.io.IOException
java.io.IOException
public static java.io.File createTempFile(java.io.File dir, java.lang.String prefix, java.lang.String suffix) throws java.io.IOException
java.io.IOException
public static java.io.File createTempFile(java.io.File dir, java.lang.String prefix, java.lang.String suffix, boolean create) throws java.io.IOException
java.io.IOException
public static java.io.File createTempFile(java.io.File dir, java.lang.String prefix, java.lang.String suffix, boolean create, boolean deleteOnExit) throws java.io.IOException
java.io.IOException
public static java.lang.String getTempDirectory()
public static java.io.File generateRandomTemporaryPath() throws java.io.IOException
java.io.IOException
@Deprecated public static void setExecutableAttribute(java.lang.String path, boolean executableFlag) throws java.io.IOException
FileUtil
or File
methods; for removal in IDEA 2020java.io.IOException
public static java.lang.String loadFile(java.io.File file) throws java.io.IOException
java.io.IOException
public static java.lang.String loadFile(java.io.File file, boolean convertLineSeparators) throws java.io.IOException
java.io.IOException
public static java.lang.String loadFile(java.io.File file, java.lang.String encoding) throws java.io.IOException
java.io.IOException
public static java.lang.String loadFile(java.io.File file, java.lang.String encoding, boolean convertLineSeparators) throws java.io.IOException
java.io.IOException
public static char[] loadFileText(java.io.File file) throws java.io.IOException
java.io.IOException
public static char[] loadFileText(java.io.File file, java.lang.String encoding) throws java.io.IOException
java.io.IOException
public static char[] loadFileText(java.io.File file, java.nio.charset.Charset encoding) throws java.io.IOException
java.io.IOException
public static char[] loadText(java.io.Reader reader, int length) throws java.io.IOException
java.io.IOException
public static java.util.List<java.lang.String> loadLines(java.io.File file) throws java.io.IOException
java.io.IOException
public static java.util.List<java.lang.String> loadLines(java.io.File file, java.lang.String encoding) throws java.io.IOException
java.io.IOException
public static java.util.List<java.lang.String> loadLines(java.lang.String path) throws java.io.IOException
java.io.IOException
public static java.util.List<java.lang.String> loadLines(java.lang.String path, java.lang.String encoding) throws java.io.IOException
java.io.IOException
public static java.util.List<java.lang.String> loadLines(java.io.BufferedReader reader) throws java.io.IOException
java.io.IOException
public static byte[] loadBytes(java.io.InputStream stream) throws java.io.IOException
java.io.IOException
public static boolean isTooLarge(long len)
public static byte[] loadBytes(java.io.InputStream stream, int length) throws java.io.IOException
java.io.IOException
public static java.io.File getParentFile(java.io.File file)
file
- a file to analyzenull
if the file has no parent.public static boolean delete(java.io.File file)
file
- file or directory to deletepublic static <T,E extends java.lang.Throwable> T doIOOperation(FileUtilRt.RepeatableIOOperation<T,E> ioTask) throws E extends java.lang.Throwable
E extends java.lang.Throwable
protected static boolean deleteFile(java.io.File file)
public static boolean ensureCanCreateFile(java.io.File file)
public static boolean createIfNotExists(java.io.File file)
public static boolean createParentDirs(java.io.File file)
public static boolean createDirectory(java.io.File path)
public static void copy(java.io.File fromFile, java.io.File toFile) throws java.io.IOException
java.io.IOException
public static void copy(java.io.InputStream inputStream, java.io.OutputStream outputStream) throws java.io.IOException
java.io.IOException
public static byte[] getThreadLocalBuffer()
public static int getUserFileSizeLimit()
public static int getUserContentLoadLimit()