Package fr.paris.lutece.util.file
Class FileUtil
- java.lang.Object
-
- fr.paris.lutece.util.file.FileUtil
-
public final class FileUtil extends java.lang.ObjectUtility class for files
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringCONSTANT_MIME_TYPE_CSVstatic java.lang.StringCONSTANT_MIME_TYPE_ZIPstatic java.lang.StringEXTENSION_CSVstatic java.lang.StringEXTENSION_ZIP
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voiddeleteFile(java.io.File file)Delete the file.static booleanhasFreemarkerExtension(java.lang.String strFileName)Check if a file has a valid Freemarker extensionstatic booleanhasHtmlExtension(java.lang.String strFileName)Check if a file has a valid html extensionstatic booleanhasImageExtension(java.lang.String strImageFileName)Check if the extension of the file is an image extensionstatic java.lang.StringnormalizeFileName(java.lang.String string)Converts French diacritics characters into non diacritics.static voidzipFiles(java.nio.file.Path zipFile, java.nio.file.Path... paths)creates a zip file
-
-
-
Field Detail
-
CONSTANT_MIME_TYPE_ZIP
public static final java.lang.String CONSTANT_MIME_TYPE_ZIP
- See Also:
- Constant Field Values
-
CONSTANT_MIME_TYPE_CSV
public static final java.lang.String CONSTANT_MIME_TYPE_CSV
- See Also:
- Constant Field Values
-
EXTENSION_ZIP
public static final java.lang.String EXTENSION_ZIP
- See Also:
- Constant Field Values
-
EXTENSION_CSV
public static final java.lang.String EXTENSION_CSV
- See Also:
- Constant Field Values
-
-
Method Detail
-
hasImageExtension
public static boolean hasImageExtension(java.lang.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(java.lang.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(java.lang.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(java.nio.file.Path zipFile, java.nio.file.Path... paths) throws java.io.IOExceptioncreates a zip file- Parameters:
zipFile- the zipfile to createfiles- to add to the Zip- Throws:
java.io.IOException
-
normalizeFileName
public static final java.lang.String normalizeFileName(java.lang.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(java.io.File file)
Delete the file.
Logs an error if the delete is not succesful.- Parameters:
pathname-
-
-