|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.semanticdesktop.aperture.util.FileUtil
public class FileUtil
Utility methods for operations on Files.
Constructor Summary | |
---|---|
FileUtil()
|
Method Summary | |
---|---|
static void |
copyFile(File source,
File destination)
Copies the contents of file source to file destination. |
static void |
createDirIfNotExists(File dir)
Creates a directory if it doesn't exist yet. |
static boolean |
deleteChildren(File directory)
Deletes all files and directories in the specified directory. |
static boolean |
deltree(File directory)
Deletes the given file and everything under it. |
static String |
getFileExtension(String fileName)
Gets the extension of the specified file name. |
static File |
getRelativeFile(File subj,
File relativeTo)
Gets the relative representations of a file compared to another. |
static String |
getRelativePath(File subj,
File relativeTo)
Gets the relative representations of a file compared to another. |
static boolean |
isLegalFileName(String fileName)
Checks whether the specified file name is a legal (DOS/Windows-) file name. |
static boolean |
isLegalFileNameChar(char c)
Checks whether the specified character is a legal (DOS/Windows-) file name character. |
static boolean |
moveRecursive(File from,
File to,
Collection excludes)
Moves the given file and all files under it (if it's a directory) to the given location, excluding the given collection of File objects! |
static String |
readStreamAsEncoding(InputStream in,
String encoding)
|
static String |
readStreamAsUTF8(InputStream in)
|
static String |
readWholeFileAsEncoding(String filename,
String encoding)
|
static String |
readWholeFileAsUTF8(String filename)
Read a whole file as UTF-8 |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public FileUtil()
Method Detail |
---|
public static String getRelativePath(File subj, File relativeTo)
subj
- The File to find the relative form for.relativeTo
- The File 'subj' should be made relative to.
public static File getRelativeFile(File subj, File relativeTo)
subj
- The File to find the relative form for.relativeTo
- The File 'subj' should be made relative to.
public static String getFileExtension(String fileName)
fileName
- The file name to process.
public static boolean isLegalFileName(String fileName)
public static boolean isLegalFileNameChar(char c)
public static void copyFile(File source, File destination) throws IOException
IOException
public static void createDirIfNotExists(File dir) throws IOException
dir
- The directory to create.
IOException
- If the creation of the directory failed.public static boolean deltree(File directory)
public static boolean deleteChildren(File directory)
public static boolean moveRecursive(File from, File to, Collection excludes)
from
- File or directory to be movedto
- The file or directory to rename toexcludes
- The File objects to be excluded; if a directory is excluded, all files under it
are excluded as well!
public static String readWholeFileAsUTF8(String filename) throws IOException
filename
-
IOException
- Stolen from Jenapublic static String readStreamAsUTF8(InputStream in) throws IOException
IOException
public static String readStreamAsEncoding(InputStream in, String encoding) throws IOException
IOException
public static String readWholeFileAsEncoding(String filename, String encoding) throws IOException
IOException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |