public class FileUtil extends Object
Modifier and Type | Field and Description |
---|---|
protected static org.slf4j.Logger |
log |
Constructor and Description |
---|
FileUtil() |
Modifier and Type | Method and Description |
---|---|
static void |
appendFile(String text,
String filepath) |
static String |
computeDigest(File file)
This method calculates the digest of a file using the algorithm SHA-1.
|
static String |
computeDigest(InputStream is) |
static byte[] |
computeSha1Hash(File file)
This method calculates the digest of a file using the algorithm SHA-1.
|
static byte[] |
computeSha1Hash(InputStream is)
This method calculates the digest of a inputStram content using the
algorithm SHA-1.
|
static void |
copyFile(File sourceFile,
File destFile) |
static void |
copyResource(String resourceName,
File out)
Writes the specified classpath resource into a file
|
static String |
getDisplaySize(long size,
String language)
Renders a file size in a more readable behaviour taking into account the
user locale.
|
static String |
getDisplaySizeKB(long size,
String language)
Renders a file size in a more readable behaviour taking into account the
user locale.
|
static long |
getFolderSize(File folder)
Computes the folder size as the sum of all files directly and indirectly
contained.
|
static boolean |
matches(String filename,
String[] includes,
String[] excludes)
Check if a given filename matches the
includes and not the
excludes |
static boolean |
matches(String filename,
String includes,
String excludes)
Check if a given filename matches the
includes and not the
excludes |
static void |
replaceInFile(String sourcePath,
String token,
String newValue) |
static void |
strongDelete(File file) |
static byte[] |
toByteArray(File file) |
static void |
writeFile(InputStream in,
String filepath) |
static void |
writeFile(String text,
String filepath) |
static void |
writeUTF8(String content,
File file,
boolean append) |
public static void writeFile(InputStream in, String filepath) throws Exception
Exception
public static String computeDigest(InputStream is)
public static String computeDigest(File file)
file
- The file for which will be computed the digestpublic static byte[] computeSha1Hash(File file)
file
- The file for which will be computed the digestpublic static byte[] computeSha1Hash(InputStream is)
file
- The file for which will be computed the digestpublic static void copyResource(String resourceName, File out) throws IOException
resourceName
- Fully qualified resource nameout
- The output fileIOException
public static long getFolderSize(File folder)
public static String getDisplaySize(long size, String language)
size
- Size to be renderedlanguage
- The language for the format symbolspublic static String getDisplaySizeKB(long size, String language)
size
- Size to be renderedlanguage
- The language for the format symbolspublic static boolean matches(String filename, String[] includes, String[] excludes)
includes
and not the
excludes
filename
- The filename to considerincludes
- list of includes expressions (eg. *.doc,*dummy*)excludes
- list of excludeses expressions (eg. *.doc,*dummy*)public static boolean matches(String filename, String includes, String excludes)
includes
and not the
excludes
filename
- The filename to considerincludes
- comma-separated list of includes expressions (eg.
*.doc,*dummy*)excludes
- comma-separated list of excludeses expressions (eg.
*.doc,*dummy*)public static byte[] toByteArray(File file)
public static void replaceInFile(String sourcePath, String token, String newValue) throws Exception
Exception
public static void copyFile(File sourceFile, File destFile) throws IOException
IOException
public static void strongDelete(File file)
Copyright © 2008-2014 Logical Objects. All Rights Reserved.