|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.neeve.util.UtlFile
public final class UtlFile
Utility class containing methods to work with files and directories.
This class MAY be used by end users, however it is not supported.
Field Summary | |
---|---|
static String |
FILE_USENATIVE_PROPNAME
|
Constructor Summary | |
---|---|
UtlFile()
|
Method Summary | |
---|---|
static void |
copyDirectory(File source,
File dest)
Recursively copy a directory. |
static void |
copyDirectory(File source,
File dest,
FilenameFilter filter)
Recursively copy filtered contents of a directory. |
static void |
copyDirectory(File source,
File dest,
FilenameFilter filter,
boolean recursive)
Copy a directory. |
static void |
copyFile(File source,
File dest)
Copy a file |
static void |
copyFile(File source,
File dest,
Properties replacementMap)
|
static void |
copyFileWithNamespaceToDirectory(File source,
File destination,
String namespace,
String nameWithExtension)
Copies file to multiple directory, creating it if it doesn't exist. |
static void |
copyToFile(InputStream is,
File target)
|
static File |
copyToTempFile(InputStream is)
|
static void |
deleteDirectory(File dir)
|
static String |
expandPath(String path)
Expands the given String path with any path variables such as user home directory (e.g. |
static Collection<File> |
findFilesByEnding(File dir,
String ending)
Searches a directory recursively to find files that match given ending, ignoring case. |
static String |
getUserHome()
Returns the current user's home directory. |
static File |
getUserHomeDir()
Returns the current user's home directory. |
static boolean |
isNativeFileIOEnabled()
|
static void |
nativeDestroy(long nfile)
Destroy a native file object |
static long |
nativeWrap(int fd)
Wrap a native file object around a file descriptor |
static long |
nativeWrite(long nsc,
ByteBuffer[] buffers,
int count)
Write a set of byte buffers to a native file |
static File |
newDirWithNamespace(File parent,
String namespace)
Creates File instance of directory with dot-separated namespace appended to the path. |
static File |
newFileWithNamespace(File parent,
String namespace,
String nameWithExtension)
Equivalent to calling newFileWithNamespace(File, String, String, String) with extension = null. |
static File |
newFileWithNamespace(File parent,
String namespace,
String name,
String extension)
Convenience helper for constructing File instances that involve java-style namespaces as their segment. |
static String |
readableFileSize(long size)
|
static String |
readFile(File file,
String charset)
Reads a file into a String. |
static String |
relativePath(File directory,
File file)
Gets the path to the given file relative to the given directory. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String FILE_USENATIVE_PROPNAME
Constructor Detail |
---|
public UtlFile()
Method Detail |
---|
public static final boolean isNativeFileIOEnabled()
public static final long nativeWrap(int fd) throws Exception
Exception
public static final long nativeWrite(long nsc, ByteBuffer[] buffers, int count) throws Exception
Exception
public static final void nativeDestroy(long nfile)
public static final void copyFile(File source, File dest) throws IOException
IOException
public static final void copyFileWithNamespaceToDirectory(File source, File destination, String namespace, String nameWithExtension) throws IOException
source
- Source file to copy.destination
- Destination directory.namespace
- dot-separated namespace for destination file. Will be converted to file path segment prepended to file name.nameWithExtension
- File name with extension.
IOException
- if file read/write operation fails.public static final void copyFile(File source, File dest, Properties replacementMap) throws IOException
IOException
public static final File copyToTempFile(InputStream is) throws IOException
IOException
public static final void copyToFile(InputStream is, File target) throws IOException
IOException
public static final void copyDirectory(File source, File dest, FilenameFilter filter, boolean recursive) throws IOException
source
- The directory to copy.dest
- The destination to copy it to.filter
- The filename filter to apply. A value of null results in
the entire contents being copied.recursive
- Specifies whether the directory should be copied
recursively.
IOException
public static final void copyDirectory(File source, File dest, FilenameFilter filter) throws IOException
source
- The directory to copy.dest
- The destination to copy it to.filter
- The filename filter to apply. A value of null results in
the entire contents being copied.
IOException
public static final void copyDirectory(File source, File dest) throws IOException
source
- The directory to copy.dest
- The destination to copy it to.
IOException
public static final void deleteDirectory(File dir) throws IOException
IOException
public static String readableFileSize(long size)
public static String relativePath(File directory, File file)
directory
- The directory.file
- The file
public static final String getUserHome()
public static final File getUserHomeDir()
public static String expandPath(String path)
path
- The path to be expanded.
public static final String readFile(File file, String charset) throws IOException
file
- The filecharset
- The character set to use for file content
IOException
- If there is an error reading the filepublic static final File newFileWithNamespace(File parent, String namespace, String name, String extension)
parent
- Parent directorynamespace
- dot-separated namespace component that is converted to filesystem path segment prepended to file.name
- File name.extension
- Filename extension excluding dot character.
File
instance.public static final File newFileWithNamespace(File parent, String namespace, String nameWithExtension)
newFileWithNamespace(File, String, String, String)
with extension = null.
parent
- Parent directorynamespace
- dot-separated namespace component that is converted to filesystem path segment prepended to file.nameWithExtension
- File name with extension included.
File
instance.public static final File newDirWithNamespace(File parent, String namespace)
parent
- Parent directory.namespace
- Namespace to append to directory path.
public static final Collection<File> findFilesByEnding(File dir, String ending)
dir
- Directory to visit recursively.ending
- Extension to match, excluding the preceding dot.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |