Package com.kheops.util
Class KFileUtil
java.lang.Object
com.kheops.util.KFileUtil
KFileUtil contains usefull methods for files manipulation.
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionstatic booleancopyDirectory(File source, File dest) Copies the content of the source directory in the specified directory.static booleancopyDirectory(File source, File dest, boolean overwriteFile) Copies the content of the source directory in the specified directory.static booleancopyDirectory(File source, File dest, String[] filters) Copies the content of the source directory in the specified directory.static booleancopyDirectory(File source, File dest, String[] filters, boolean overwriteFile) Copies the content of the source directory in the specified directory.static booleanCopies the specifies source file to the destination file.static booleanCopies the specifies source file to the destination file.static booleanCopies the specifies source file to the destination file.static booleanCopies the specifies source file to the destination file.static booleandeleteDirectory(File dir) Deletes a directory recursivelystatic StringReturns the current date formatted like: '2002-04-17'.static Stringstatic Attributesstatic 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 PropertiesloadPropertiesFile(File file) Loads a Properties file.static PropertiesloadPropertiesFile(File file, Charset charset) static byte[]Returns the content of the specified file.static voidsavePropertiesFile(Properties prop, File fileName, String header) static voidsetFileContent(File f, byte[] buffer) static voidsetFileContent(File f, String buffer) static booleanUnzips the content of the specified compressed file to the specified destination directory.static voidstatic booleanzipDirectory(File source, File dest, boolean recursive) Zips the content of the specified directory to the specified destination file.static booleanzipDirectory(File source, OutputStream stream, boolean recursive) 
- 
Constructor Details- 
KFileUtilpublic KFileUtil()
 
- 
- 
Method Details- 
listFilesLists 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 from
- filters- filters to match the files with
- Returns:
- all files matching the specified filter from the specified directory
 
- 
listFilesLists 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 from
- filters- filters to match the files with
- Returns:
- all files matching the specified filter from the specified directory
 
- 
listFilesLists 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 from
- filters- filters to match the files with
- Returns:
- all files matching the specified filter from the specified directory
 
- 
readFileReturns 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
 
- 
copyDirectoryCopies 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
 
- 
copyDirectorypublic 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 directory
- dest- the destination directory
- Returns:
- true if the copy successful
- Throws:
- IOException- if an error occurs during the copy
 
- 
copyDirectoryCopies 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
 
- 
copyDirectorypublic 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 directory
- dest- the destination directory
- filters- 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
 
- 
unzipFileUnzips the content of the specified compressed file to the specified destination directory.- Parameters:
- source- the compressed file
- dest- the destination directory.
- Returns:
- true if the operation completes successfully
- Throws:
- IOException- if an error occurs
 
- 
zipDirectoryZips the content of the specified directory to the specified destination file.- Parameters:
- source- the source directory
- dest- 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
 
- 
zipDirectorypublic static boolean zipDirectory(File source, OutputStream stream, boolean recursive) throws IOException - Throws:
- IOException
 
- 
copyFileCopies the specifies source file to the destination file. File is overwritten if already exist- Throws:
- IOException
 
- 
copyFileCopies the specifies source file to the destination file.- Parameters:
- source- the file to be copied
- dest- the destination file
- Returns:
- true if the operation completes successfully
- Throws:
- IOException- if an error occurs
 
- 
copyFileCopies the specifies source file to the destination file. File is overwritten if already exist- Throws:
- IOException
 
- 
copyFileCopies the specifies source file to the destination file.- Parameters:
- source- the file to be copied
- dest- the destination file
- Returns:
- true if the operation completes successfully
- Throws:
- IOException- if an error occurs
 
- 
getDatedFileNameReturns 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'.
 
- 
deleteDirectoryDeletes a directory recursively- Parameters:
- dir- the directory to delete
 
- 
loadPropertiesFileLoads 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
 
 
-