Package fr.paris.lutece.util.file
Class FileUtil
- java.lang.Object
-
- fr.paris.lutece.util.file.FileUtil
-
public final class FileUtil extends Object
Utility class for files
-
-
Field Summary
Fields Modifier and Type Field Description static StringCONSTANT_MIME_TYPE_CSVstatic StringCONSTANT_MIME_TYPE_ZIPstatic StringEXTENSION_CSVstatic StringEXTENSION_ZIP
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voiddeleteFile(File file)Delete the file.static booleanhasFreemarkerExtension(String strFileName)Check if a file has a valid Freemarker extensionstatic booleanhasHtmlExtension(String strFileName)Check if a file has a valid html extensionstatic booleanhasImageExtension(String strImageFileName)Check if the extension of the file is an image extensionstatic StringnormalizeFileName(String string)Converts French diacritics characters into non diacritics.static voidzipFiles(Path zipFile, Path... paths)creates a zip file
-
-
-
Field Detail
-
CONSTANT_MIME_TYPE_ZIP
public static final String CONSTANT_MIME_TYPE_ZIP
- See Also:
- Constant Field Values
-
CONSTANT_MIME_TYPE_CSV
public static final String CONSTANT_MIME_TYPE_CSV
- See Also:
- Constant Field Values
-
EXTENSION_ZIP
public static final String EXTENSION_ZIP
- See Also:
- Constant Field Values
-
EXTENSION_CSV
public static final String EXTENSION_CSV
- See Also:
- Constant Field Values
-
-
Method Detail
-
hasImageExtension
public static boolean hasImageExtension(String strImageFileName)
Check if the extension of the file is an image extension- Parameters:
strImageFileName- The file name to check- Returns:
- True if the extension is correct, false otherwise
-
hasHtmlExtension
public static boolean hasHtmlExtension(String strFileName)
Check if a file has a valid html extension- Parameters:
strFileName- The file name to check- Returns:
- True if the file name is valid, false otherwise
-
hasFreemarkerExtension
public static boolean hasFreemarkerExtension(String strFileName)
Check if a file has a valid Freemarker extension- Parameters:
strFileName- The file name to check- Returns:
- True if the file name is valid, false otherwise
-
zipFiles
public static void zipFiles(Path zipFile, Path... paths) throws IOException
creates a zip file- Parameters:
zipFile- the zipfile to createfiles- to add to the Zip- Throws:
IOException
-
normalizeFileName
public static final String normalizeFileName(String string)
Converts French diacritics characters into non diacritics.
Replace whitespaces by underscores
Keep only underscores and alphanum characters
Transform to lowercase- Parameters:
string-- Returns:
-
deleteFile
public static void deleteFile(File file)
Delete the file.
Logs an error if the delete is not succesful.- Parameters:
pathname-
-
-