|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sf.mmapps.commons.util.FileUtil
public class FileUtil
Nested Class Summary | |
---|---|
static class |
FileUtil.DirectoryOnlyFilter
|
static class |
FileUtil.FileOnlyFilter
|
static class |
FileUtil.IgnoreFilter
The directory filter class is used to filter files in a directory based on whether the child itself is a directory or not. |
Constructor Summary | |
---|---|
FileUtil()
|
Method Summary | |
---|---|
static boolean |
checkFileExists(java.lang.String fileName)
|
static boolean |
checkFileNameCaseSensitive(java.lang.String path)
check if a file or directory exists on disk. |
static void |
copyFolderContent(java.lang.String origin,
java.lang.String destination,
java.io.FileFilter filter)
Copy files from String origin to String destination. |
static void |
copyStream(java.io.InputStream inputStream,
java.io.OutputStream outputStream)
Copy an InputStream to an OutputStream |
static boolean |
deleteFile(java.io.File f)
delete a file or directory (and all its content) |
static boolean |
deleteFile(java.io.File f,
boolean contentOnly)
delete a file or directory ( and all its contains ) |
java.io.File[] |
getChildFiles(java.lang.String path)
Get all the child files (i.e. no directories) for a given relative path. |
java.io.File |
getFileFromPath(java.lang.String path)
Given a path relative to the staging root, fetch the file. |
static java.io.InputStream |
getInputStream(java.lang.String fileName)
|
java.io.File |
getParent(java.io.File child)
Get the parent of a specific child folder |
java.lang.String |
getPathFromFile(java.io.File file,
boolean urlEncode)
Get the path of a directory or file relative to the root. |
static void |
moveFolderContent(java.lang.String origin,
java.lang.String destination,
java.io.FileFilter filter)
Move files from String origin to String destination. |
static java.lang.String |
readString(java.lang.String name)
|
static java.lang.String |
readString(java.lang.String name,
int skiplines,
boolean keepLines)
|
static java.lang.String |
removeFileExtension(java.lang.String filename,
java.lang.String ext)
Return the file name but without the extension |
static void |
writeBytesInFile(java.lang.String fileName,
byte[] bytes)
|
static void |
writeFileInFile(java.lang.String fileName,
java.lang.String destinationFile)
|
static void |
writeStreamInFile(java.lang.String fileName,
java.io.InputStream input)
|
static void |
writeStringInFile(java.lang.String fileName,
java.lang.String output)
Write a string in a file. |
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 java.lang.String readString(java.lang.String name)
public static java.lang.String readString(java.lang.String name, int skiplines, boolean keepLines)
public static void moveFolderContent(java.lang.String origin, java.lang.String destination, java.io.FileFilter filter) throws java.io.IOException
origin
- original folderdestination
- destination folderfilter
- move only matching files
java.io.IOException
- when an error occurspublic static void copyFolderContent(java.lang.String origin, java.lang.String destination, java.io.FileFilter filter) throws java.io.IOException
origin
- original folderdestination
- destination folderfilter
- move only matching files
java.io.IOException
- when an error occurspublic static void writeStringInFile(java.lang.String fileName, java.lang.String output)
fileName
- File name.output
- String output.public static void writeFileInFile(java.lang.String fileName, java.lang.String destinationFile) throws java.io.IOException
java.io.IOException
public static java.io.InputStream getInputStream(java.lang.String fileName) throws java.io.FileNotFoundException
java.io.FileNotFoundException
public static void writeBytesInFile(java.lang.String fileName, byte[] bytes) throws java.io.IOException
java.io.IOException
public static void writeStreamInFile(java.lang.String fileName, java.io.InputStream input) throws java.io.IOException
java.io.IOException
public static void copyStream(java.io.InputStream inputStream, java.io.OutputStream outputStream) throws java.io.IOException
inputStream
- inputoutputStream
- output
java.io.IOException
- when an error occurspublic static boolean checkFileExists(java.lang.String fileName)
public static boolean checkFileNameCaseSensitive(java.lang.String path)
path
- the absolute path
public static boolean deleteFile(java.io.File f)
f
- the abstract file object
public static boolean deleteFile(java.io.File f, boolean contentOnly)
f
- the abstract file objectcontentOnly
- id true, delete only the folder content
public static java.lang.String removeFileExtension(java.lang.String filename, java.lang.String ext)
filename
- the complete file name with extensionext
- the extension to remove @return(String) the filename
without a gived extension
public java.io.File getParent(java.io.File child)
child
- Child whose parent is to be retrieved
public java.io.File[] getChildFiles(java.lang.String path)
path
- Path of files to retrieve.
public java.lang.String getPathFromFile(java.io.File file, boolean urlEncode)
file
- File whose path is to be retrieved.urlEncode
- If set to true, the returned path will be URL encoded.
public java.io.File getFileFromPath(java.lang.String path)
path
- Path of file to retrieve.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |