|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.wicket.util.file.Files
public class Files
File utility methods.
Method Summary | |
---|---|
static java.lang.String |
basePath(java.lang.String path,
java.lang.String extension)
Strips off the given extension (probably returned from Files.extension()) from the path, yielding a base pathname. |
static java.lang.String |
cleanupFilename(java.lang.String filename)
Replaces commonly unsupported characters with '_' |
static void |
copy(java.io.File sourceFile,
java.io.File targetFile)
make a copy of a file |
static java.lang.String |
extension(java.lang.String path)
Gets extension from path |
static java.lang.String |
filename(java.lang.String path)
Gets filename from path |
static Time |
getLastModified(java.io.File file)
get last modification timestamp for file |
static java.io.File |
getLocalFileFromUrl(java.lang.String url)
for urls that point to local files (e.g. |
static java.io.File |
getLocalFileFromUrl(java.net.URL url)
for urls that point to local files (e.g. |
static boolean |
mkdirs(java.io.File folder)
Utility method for creating a directory. |
static byte[] |
readBytes(java.io.File file)
read binary file fully |
static boolean |
remove(java.io.File file)
Deletes a normal file. |
static boolean |
removeAsync(java.io.File file,
IFileCleaner fileCleaner)
Schedules a file for removal asynchronously. |
static boolean |
removeFolder(java.io.File folder)
Deletes a folder by recursively removing the files and folders inside it. |
static boolean |
removeFolderAsync(java.io.File folder,
IFileCleaner fileCleaner)
Schedules a folder and all files inside it for asynchronous removal. |
static int |
writeTo(java.io.File file,
java.io.InputStream input)
Writes the given input stream to the given file |
static int |
writeTo(java.io.File file,
java.io.InputStream input,
int bufSize)
Writes the given input stream to the given file |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static java.lang.String basePath(java.lang.String path, java.lang.String extension)
path
- The path, possibly with an extension to stripextension
- The extension to strip, or null if no extension exists
public static java.lang.String extension(java.lang.String path)
path
- The path
public static java.lang.String filename(java.lang.String path)
path
- The path
public static boolean remove(java.io.File file)
If the file cannot be deleted for any reason then at most 50 retries are attempted with delay of 100ms at each 10th attempt.
file
- the file to delete
true
if file was deleted, false
if the file don't exist, is a folder
or cannot be removed for some reasonpublic static final boolean removeFolder(java.io.File folder)
remove(File)
for plain files.
folder
- the folder to delete
true
if the folder is deleted successfully.public static final boolean removeAsync(java.io.File file, IFileCleaner fileCleaner)
file
- the file to be removedfileCleaner
- the file cleaner that will be used to remove the file
false
if the file
is null or a folder, true
-
otherwise (i.e. if it is scheduled)public static final boolean removeFolderAsync(java.io.File folder, IFileCleaner fileCleaner)
folder
- the folder to be removedfileCleaner
- the file cleaner that will be used to remove the file
false
if the folder
is null or a normal file, true
-
otherwise (i.e. if it is scheduled)public static final int writeTo(java.io.File file, java.io.InputStream input) throws java.io.IOException
file
- The file to write toinput
- The input
java.io.IOException
public static byte[] readBytes(java.io.File file) throws java.io.IOException
file
- file to read
java.io.IOException
- is something went wrongpublic static final int writeTo(java.io.File file, java.io.InputStream input, int bufSize) throws java.io.IOException
file
- The file to write toinput
- The inputbufSize
- The memory buffer size. 4096 is a good value.
java.io.IOException
public static final java.lang.String cleanupFilename(java.lang.String filename)
Replaces commonly unsupported characters with '_'
filename
- to be cleaned
public static void copy(java.io.File sourceFile, java.io.File targetFile) throws java.io.IOException
sourceFile
- source file that needs to be clonedtargetFile
- target file that should be a duplicate of source file
java.io.IOException
- if something went wrongpublic static java.io.File getLocalFileFromUrl(java.net.URL url)
url
- url of the resource
null
otherwisegetLocalFileFromUrl(String)
public static java.io.File getLocalFileFromUrl(java.lang.String url)
url
- url of the resource
null
otherwisegetLocalFileFromUrl(URL)
public static Time getLastModified(java.io.File file)
file
-
public static boolean mkdirs(java.io.File folder)
folder
- the folder to create
true
if the creation is successful, false
- otherwise
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |