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