public class FileUtil extends java.lang.Object
Constructor and Description |
---|
FileUtil() |
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
appendNewLine(java.lang.String s) |
static java.lang.String |
clean(java.io.File f)
Always return the true unique string representation of
a file with no trailing separators.
|
static java.lang.String |
convertStreamToString(java.io.InputStream is) |
static void |
copyDirectory(java.io.File sourceLocation,
java.io.File targetLocation,
boolean overwrite)
Copy a file or directory to another.
|
static java.lang.String |
getExtension(java.io.File f) |
static java.lang.String |
getFileNameWithoutExtension(java.lang.String filename)
Return filename without extension.
|
static java.io.File |
getHighestRankedFile(java.lang.String relativePath)
Return the highest ranked (i.e. top override) of the given
relative file path.
|
static java.io.File |
getResourceAsFile(java.lang.Object relativeTo,
java.lang.String relativePath)
Get a File object from a resource on the classpath using the
ClassLoader that loaded the given object.
|
static boolean |
isSubdirectory(java.io.File base,
java.io.File sub) |
static java.lang.String[] |
pathRep(java.io.File f)
Return a string array representation of the file path.
|
static java.lang.String |
readFileAsString(java.io.File file)
Read in a file as a string.
|
public FileUtil()
public static java.io.File getHighestRankedFile(java.lang.String relativePath)
relativePath
- public static java.io.File getResourceAsFile(java.lang.Object relativeTo, java.lang.String relativePath)
relativeTo
- relativePath
- public static java.lang.String readFileAsString(java.io.File file) throws java.io.IOException
f
- java.io.IOException
public static java.lang.String convertStreamToString(java.io.InputStream is) throws java.io.IOException
java.io.IOException
public static java.lang.String appendNewLine(java.lang.String s)
public static boolean isSubdirectory(java.io.File base, java.io.File sub) throws java.io.IOException
base
- sub
- java.io.IOException
public static java.lang.String[] pathRep(java.io.File f) throws java.io.IOException
f
- java.io.IOException
public static java.lang.String clean(java.io.File f) throws java.io.IOException
f
- java.io.IOException
public static java.lang.String getFileNameWithoutExtension(java.lang.String filename)
filename
- public static java.lang.String getExtension(java.io.File f)
public static void copyDirectory(java.io.File sourceLocation, java.io.File targetLocation, boolean overwrite) throws java.io.IOException
sourceLocation
- the sourcetargetLocation
- the destinationoverwrite
- If true, overwrite files in the targetLocationjava.io.IOException