|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.groiss.util.FileUtil
public class FileUtil
Some convenient file methods.
Constructor Summary | |
---|---|
FileUtil()
|
Method Summary | |
---|---|
static void |
copyFileOrDirectory(java.io.File src,
java.io.File dest)
copies a file or a whole folder to the given destination |
static void |
copyTo(java.io.File src,
java.io.File dest)
Copy a file. |
static java.io.File |
copyToDir(java.io.File src,
java.io.File dir)
Copy file to directory |
static void |
createJarMetaInf(java.util.jar.JarOutputStream jarOut,
java.util.Map<java.lang.String,java.lang.String> properties)
|
static void |
deleteDir(java.io.File dir)
Deletes the passed direcory and all its subdirectories (and so on). |
static void |
deleteDir(java.lang.String dirPath)
Deletes the direcory with the given path. |
static byte[] |
getBytesFromStream(java.io.InputStream is)
Load the content of an InputStream into a byte array. |
static java.lang.String |
getContent(java.io.File file)
Get the content of a file as string. |
static java.lang.String |
getContent(java.lang.String filename)
|
static java.io.File |
getFileFromPath(java.lang.String path)
Get a file object from a pathname. |
protected static java.lang.String |
getLogPrefix(int level)
|
static java.io.PrintWriter |
getLogWriter(java.lang.String fileName,
int maxLogs)
|
static java.lang.String |
getMimeType(java.lang.String ext)
Return the mime-type from the extension. |
static java.lang.String |
getNoComment(java.io.InputStream in)
|
static java.lang.String |
getNoComment(java.io.Reader in)
Get the contents of an input stream without the comments. |
static java.lang.String |
getNoCommentContent(java.lang.String filename)
|
static java.lang.String |
getShinyPathMapping(java.lang.String path)
Returns the shiny path for the passed resource path. |
static boolean |
isTextFile(java.lang.String pathname)
Returns true if the mime-time of this file starts with text |
static java.util.List<java.io.File> |
listFiles(java.lang.String namePattern,
java.io.File dir)
List file with name specified with wildcard in directory and all its subdirectories. |
static java.util.List<java.io.File> |
listFiles(java.lang.String namePattern,
java.io.File dir,
boolean recursive)
List file with name specified with wildcard in directory. |
static org.jdom.Document |
loadApplicationResource(java.lang.String resource)
Load a resource, i.e. |
static java.lang.String |
loadResource(java.lang.String resource)
Load a resource as string from the classpath. |
static java.lang.String |
loadResource(java.net.URL url)
Load a resource as string from an url. |
static byte[] |
loadResourceBytes(java.lang.String resource)
|
static byte[] |
loadResourceBytes(java.net.URL url)
Load a resource as byte array from the classpath. |
static java.lang.String |
loadResourceFromStream(java.io.InputStream is)
Load a resource from an input stream (file, etc.). |
static java.lang.String |
loadResourceFromStream(java.io.InputStream is,
java.lang.String charset)
|
static void |
log(java.io.PrintWriter pw,
java.lang.String str)
|
static void |
packJarFiles(java.util.jar.JarOutputStream jarOut,
java.io.File dir,
java.lang.String[] types)
|
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 getMimeType(java.lang.String ext)
ext
- the extension, for example "doc" or "html"
public static java.lang.String getShinyPathMapping(java.lang.String path)
path
- the original path of a resource
public static java.lang.String loadResource(java.lang.String resource)
resource
- a path to a resource
public static java.lang.String loadResource(java.net.URL url)
url
- the url of the resource
public static java.lang.String loadResourceFromStream(java.io.InputStream is) throws java.io.IOException
is
- an input stream
java.io.IOException
public static java.lang.String loadResourceFromStream(java.io.InputStream is, java.lang.String charset) throws java.io.IOException
java.io.IOException
public static org.jdom.Document loadApplicationResource(java.lang.String resource) throws java.io.FileNotFoundException, org.jdom.JDOMException, java.io.IOException
resource
- a path in the classpath
java.io.FileNotFoundException
java.io.IOException
org.jdom.JDOMException
public static byte[] loadResourceBytes(java.net.URL url)
url
- the url of a resource
public static byte[] loadResourceBytes(java.lang.String resource)
public static byte[] getBytesFromStream(java.io.InputStream is)
public static void copyTo(java.io.File src, java.io.File dest) throws java.io.FileNotFoundException, java.io.IOException
src
- the source filedest
- the destination file
java.io.FileNotFoundException
java.io.IOException
public static java.io.File copyToDir(java.io.File src, java.io.File dir) throws java.io.FileNotFoundException, java.io.IOException
src
- dir
-
java.io.FileNotFoundException
java.io.IOException
public static void copyFileOrDirectory(java.io.File src, java.io.File dest) throws java.io.IOException
src
- source locationdest
- destination location
java.io.IOException
public static java.lang.String getContent(java.io.File file) throws java.io.IOException
file
- the file
java.io.IOException
public static java.lang.String getNoComment(java.io.InputStream in) throws java.lang.Exception
java.lang.Exception
public static java.lang.String getNoComment(java.io.Reader in) throws java.lang.Exception
in
- the input stream
java.lang.Exception
public static java.lang.String getNoCommentContent(java.lang.String filename) throws java.lang.Exception
java.lang.Exception
public static java.lang.String getContent(java.lang.String filename) throws java.io.IOException
java.io.IOException
public static void deleteDir(java.lang.String dirPath)
dirPath
- the directory pathpublic static void deleteDir(java.io.File dir)
dir
- the directorypublic static java.io.File getFileFromPath(java.lang.String path)
path
- the path string
public static java.util.List<java.io.File> listFiles(java.lang.String namePattern, java.io.File dir)
namePattern
- dir
-
public static java.util.List<java.io.File> listFiles(java.lang.String namePattern, java.io.File dir, boolean recursive)
namePattern
- dir
- recursive
-
public static boolean isTextFile(java.lang.String pathname)
public static void createJarMetaInf(java.util.jar.JarOutputStream jarOut, java.util.Map<java.lang.String,java.lang.String> properties) throws java.io.IOException
java.io.IOException
public static void packJarFiles(java.util.jar.JarOutputStream jarOut, java.io.File dir, java.lang.String[] types)
protected static java.lang.String getLogPrefix(int level)
public static void log(java.io.PrintWriter pw, java.lang.String str)
public static java.io.PrintWriter getLogWriter(java.lang.String fileName, int maxLogs) throws java.lang.Exception
java.lang.Exception
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |