Package com.kheops.util
Class KFileUtil
java.lang.Object
com.kheops.util.KFileUtil
KFileUtil contains usefull methods for files manipulation.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
copyDirectory
(File source, File dest) Copies the content of the source directory in the specified directory.static boolean
copyDirectory
(File source, File dest, boolean overwriteFile) Copies the content of the source directory in the specified directory.static boolean
copyDirectory
(File source, File dest, String[] filters) Copies the content of the source directory in the specified directory.static boolean
copyDirectory
(File source, File dest, String[] filters, boolean overwriteFile) Copies the content of the source directory in the specified directory.static boolean
Copies the specifies source file to the destination file.static boolean
Copies the specifies source file to the destination file.static boolean
Copies the specifies source file to the destination file.static boolean
Copies the specifies source file to the destination file.static boolean
deleteDirectory
(File dir) Deletes a directory recursivelystatic String
Returns the current date formatted like: '2002-04-17'.static String
static Attributes
static File[]
Lists all files matching the specified filters from the specified directory.static File[]
Lists all files matching the specified filters from the specified directory.static File[]
Lists all files matching the specified filters from the specified directory.static Properties
loadPropertiesFile
(File file) Loads a Properties file.static Properties
loadPropertiesFile
(File file, Charset charset) static byte[]
Returns the content of the specified file.static void
savePropertiesFile
(Properties prop, File fileName, String header) static void
setFileContent
(File f, byte[] buffer) static void
setFileContent
(File f, String buffer) static boolean
Unzips the content of the specified compressed file to the specified destination directory.static void
static boolean
zipDirectory
(File source, File dest, boolean recursive) Zips the content of the specified directory to the specified destination file.static boolean
zipDirectory
(File source, OutputStream stream, boolean recursive)
-
Constructor Details
-
KFileUtil
public KFileUtil()
-
-
Method Details
-
listFiles
Lists all files matching the specified filters from the specified directory. The filter '*' returns all files. ex.:listFiles(new File("c:/temp"), new String[]{"*"});
- Parameters:
dir
- the directory to list files fromfilters
- filters to match the files with- Returns:
- all files matching the specified filter from the specified directory
-
listFiles
Lists all files matching the specified filters from the specified directory. The filter '*' returns all files. ex.:listFiles(new File("c:/temp"), new String[]{"*"});
- Parameters:
dir
- the directory to list files fromfilters
- filters to match the files with- Returns:
- all files matching the specified filter from the specified directory
-
listFiles
Lists all files matching the specified filters from the specified directory. The filter '*' returns all files. ex.:listFiles(new File("c:/temp"), new String[]{"*"});
- Parameters:
dir
- the directory to list files fromfilters
- filters to match the files with- Returns:
- all files matching the specified filter from the specified directory
-
readFile
Returns the content of the specified file.- Parameters:
file
- the file to read from- Returns:
- the content of the specified file
- Throws:
IOException
- if an error occurs
-
writeFile
- Throws:
IOException
-
copyDirectory
Copies the content of the source directory in the specified directory. If the destination doesn't exist, it will be created. File is overwritten if already exist- Throws:
IOException
-
copyDirectory
public static boolean copyDirectory(File source, File dest, boolean overwriteFile) throws IOException Copies the content of the source directory in the specified directory. If the destination doesn't exist, it will be created.- Parameters:
source
- the source directorydest
- the destination directory- Returns:
- true if the copy successful
- Throws:
IOException
- if an error occurs during the copy
-
copyDirectory
Copies the content of the source directory in the specified directory. If the destination doesn't exist, it will be created. File is overwritten if already exist- Throws:
IOException
-
copyDirectory
public static boolean copyDirectory(File source, File dest, String[] filters, boolean overwriteFile) throws IOException Copies the content of the source directory in the specified directory. If the destination doesn't exist, it will be created.- Parameters:
source
- the source directorydest
- the destination directoryfilters
- list of file extensions to copy, others are ignored. (e.g. "gif", "png", etc.)- Returns:
- true if the copy successful
- Throws:
IOException
- if an error occurs during the copy
-
unzipFile
Unzips the content of the specified compressed file to the specified destination directory.- Parameters:
source
- the compressed filedest
- the destination directory.- Returns:
- true if the operation completes successfully
- Throws:
IOException
- if an error occurs
-
zipDirectory
Zips the content of the specified directory to the specified destination file.- Parameters:
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 recursively- Returns:
- true if the operation completes successfully
- Throws:
IOException
- if an error occurs
-
zipDirectory
public static boolean zipDirectory(File source, OutputStream stream, boolean recursive) throws IOException - Throws:
IOException
-
copyFile
Copies the specifies source file to the destination file. File is overwritten if already exist- Throws:
IOException
-
copyFile
Copies the specifies source file to the destination file.- Parameters:
source
- the file to be copieddest
- the destination file- Returns:
- true if the operation completes successfully
- Throws:
IOException
- if an error occurs
-
copyFile
Copies the specifies source file to the destination file. File is overwritten if already exist- Throws:
IOException
-
copyFile
Copies the specifies source file to the destination file.- Parameters:
source
- the file to be copieddest
- the destination file- Returns:
- true if the operation completes successfully
- Throws:
IOException
- if an error occurs
-
getDatedFileName
Returns the current date formatted like: '2002-04-17'. This is the standard used for every dated files created by JMapServer.- Returns:
- the current date formatted like: '2002-04-17'.
-
deleteDirectory
Deletes a directory recursively- Parameters:
dir
- the directory to delete
-
loadPropertiesFile
Loads a Properties file.- Parameters:
file
- the Properties file to load.- Returns:
- a Properties object or null if an error occurred.
-
loadPropertiesFile
-
savePropertiesFile
-
getFileContent
- Throws:
Exception
-
setFileContent
- Throws:
Exception
-
setFileContent
- Throws:
Exception
-
getJarAttributesFromManifest
- Throws:
Exception
-