public class KFileUtil
extends java.lang.Object
Constructor and Description |
---|
KFileUtil() |
Modifier and Type | Method and Description |
---|---|
static boolean |
copyDirectory(java.io.File source,
java.io.File dest)
Copies the content of the source directory in the specified directory.
|
static boolean |
copyDirectory(java.io.File source,
java.io.File dest,
boolean overwriteFile)
Copies the content of the source directory in the specified directory.
|
static boolean |
copyDirectory(java.io.File source,
java.io.File dest,
java.lang.String[] filters)
Copies the content of the source directory in the specified directory.
|
static boolean |
copyDirectory(java.io.File source,
java.io.File dest,
java.lang.String[] filters,
boolean overwriteFile)
Copies the content of the source directory in the specified directory.
|
static boolean |
copyFile(java.io.File source,
java.io.File dest)
Copies the specifies source file to the destination file.
|
static boolean |
copyFile(java.io.File source,
java.io.File dest,
boolean overwrite)
Copies the specifies source file to the destination file.
|
static boolean |
copyFile(java.lang.String source,
java.lang.String dest)
Copies the specifies source file to the destination file.
|
static boolean |
copyFile(java.lang.String source,
java.lang.String dest,
boolean overwrite)
Copies the specifies source file to the destination file.
|
static boolean |
deleteDirectory(java.io.File dir)
Deletes a directory recursively
|
static java.lang.String |
getDatedFileName()
Returns the current date formatted like: '2002-04-17'.
|
static java.lang.String |
getFileContent(java.io.File f) |
static java.util.jar.Attributes |
getJarAttributesFromManifest(java.io.File file) |
static java.io.File[] |
listFiles(java.io.File dir,
java.lang.String[] filters,
boolean recursive)
Lists all files matching the specified filters from the specified
directory.
|
static java.io.File[] |
listFiles(java.lang.String dir,
java.lang.String[] filters)
Lists all files matching the specified filters from the specified
directory.
|
static java.io.File[] |
listFiles(java.lang.String dir,
java.lang.String[] filters,
boolean recursive)
Lists all files matching the specified filters from the specified
directory.
|
static java.util.Properties |
loadPropertiesFile(java.io.File file)
Loads a Properties file.
|
static java.util.Properties |
loadPropertiesFile(java.io.File file,
java.nio.charset.Charset charset) |
static byte[] |
readFile(java.io.File file)
Returns the content of the specified file.
|
static void |
savePropertiesFile(java.util.Properties prop,
java.io.File fileName,
java.lang.String header) |
static void |
setFileContent(java.io.File f,
byte[] buffer) |
static void |
setFileContent(java.io.File f,
java.lang.String buffer) |
static boolean |
unzipFile(java.io.File source,
java.io.File dest)
Unzips the content of the specified compressed file to the specified
destination directory.
|
static void |
writeFile(java.io.File file,
byte[] data) |
static boolean |
zipDirectory(java.io.File source,
java.io.File dest,
boolean recursive)
Zips the content of the specified directory to the specified destination
file.
|
static boolean |
zipDirectory(java.io.File source,
java.io.OutputStream stream,
boolean recursive) |
public static java.io.File[] listFiles(java.lang.String dir, java.lang.String[] filters, boolean recursive)
listFiles(new File("c:/temp"), new String[]{"*"});
dir
- the directory to list files fromfilters
- filters to match the files withpublic static java.io.File[] listFiles(java.io.File dir, java.lang.String[] filters, boolean recursive)
listFiles(new File("c:/temp"), new String[]{"*"});
dir
- the directory to list files fromfilters
- filters to match the files withpublic static java.io.File[] listFiles(java.lang.String dir, java.lang.String[] filters)
listFiles(new File("c:/temp"), new String[]{"*"});
dir
- the directory to list files fromfilters
- filters to match the files withpublic static byte[] readFile(java.io.File file) throws java.io.IOException
file
- the file to read fromjava.io.IOException
- if an error occurspublic static void writeFile(java.io.File file, byte[] data) throws java.io.IOException
java.io.IOException
public static boolean copyDirectory(java.io.File source, java.io.File dest) throws java.io.IOException
java.io.IOException
public static boolean copyDirectory(java.io.File source, java.io.File dest, boolean overwriteFile) throws java.io.IOException
source
- the source directorydest
- the destination directoryjava.io.IOException
- if an error occurs during the copypublic static boolean copyDirectory(java.io.File source, java.io.File dest, java.lang.String[] filters) throws java.io.IOException
java.io.IOException
public static boolean copyDirectory(java.io.File source, java.io.File dest, java.lang.String[] filters, boolean overwriteFile) throws java.io.IOException
source
- the source directorydest
- the destination directoryfilters
- list of file extensions to copy, others are ignored. (e.g. "gif",
"png", etc.)java.io.IOException
- if an error occurs during the copypublic static boolean unzipFile(java.io.File source, java.io.File dest) throws java.io.IOException
source
- the compressed filedest
- the destination directory.java.io.IOException
- if an error occurspublic static boolean zipDirectory(java.io.File source, java.io.File dest, boolean recursive) throws java.io.IOException
source
- the source directorydest
- the destination compressed file. If the file already exists, it
will be overwritten.recursive
- zip the content of the source directory recursivelyjava.io.IOException
- if an error occurspublic static boolean zipDirectory(java.io.File source, java.io.OutputStream stream, boolean recursive) throws java.io.IOException
java.io.IOException
public static boolean copyFile(java.lang.String source, java.lang.String dest) throws java.io.IOException
java.io.IOException
public static boolean copyFile(java.lang.String source, java.lang.String dest, boolean overwrite) throws java.io.IOException
source
- the file to be copieddest
- the destination filejava.io.IOException
- if an error occurspublic static boolean copyFile(java.io.File source, java.io.File dest) throws java.io.IOException
java.io.IOException
public static boolean copyFile(java.io.File source, java.io.File dest, boolean overwrite) throws java.io.IOException
source
- the file to be copieddest
- the destination filejava.io.IOException
- if an error occurspublic static java.lang.String getDatedFileName()
public static boolean deleteDirectory(java.io.File dir)
dir
- the directory to deletepublic static java.util.Properties loadPropertiesFile(java.io.File file)
file
- the Properties file to load.public static java.util.Properties loadPropertiesFile(java.io.File file, java.nio.charset.Charset charset)
public static void savePropertiesFile(java.util.Properties prop, java.io.File fileName, java.lang.String header)
public static java.lang.String getFileContent(java.io.File f) throws java.lang.Exception
java.lang.Exception
public static void setFileContent(java.io.File f, byte[] buffer) throws java.lang.Exception
java.lang.Exception
public static void setFileContent(java.io.File f, java.lang.String buffer) throws java.lang.Exception
java.lang.Exception
public static java.util.jar.Attributes getJarAttributesFromManifest(java.io.File file) throws java.lang.Exception
java.lang.Exception