Package io.inugami.commons.files
Class FilesUtils
- java.lang.Object
-
- io.inugami.commons.files.FilesUtils
-
public class FilesUtils extends Object
FileUtils- Since:
- 12 janv. 2017
-
-
Field Summary
Fields Modifier and Type Field Description static int
DEFAULT_BUFFER_SIZE
static int
MEGA
-
Constructor Summary
Constructors Constructor Description FilesUtils()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static void
assertCanRead(File file)
static void
assertCanWrite(File file)
static void
assertFileExists(File file)
static void
assertIsFile(File file)
static void
assertIsFolder(File file)
static File
buildFile(File file, String... part)
static String
buildPath(File file, String... part)
static void
close(Closeable closable)
static URL
convertToUrl(File file)
static boolean
copy(File source, File destination)
static boolean
delete(File file)
static String
getCanonicalPath(File file)
static long
getContentLength(File resource)
static String
getContentType(File resource)
static File
getTmpDir()
static boolean
isAbsoluteFile(String path)
static boolean
isWindows()
static List<File>
list(File folder)
static List<File>
list(File folder, FilenameFilter filter)
String
read(File file)
String
read(File file, int bufferSize)
String
read(File file, int bufferSize, String encoding)
String
read(File file, String encoding)
static byte[]
readBytes(File file)
static String
readContent(File file)
static String
readFileFromClassLoader(String resourceName)
static String
readFileFromClassLoader(String resourceName, Charset charset)
static <T extends Serializable>
TreadFromBinary(File file, T defaultValue)
static byte[]
readFromClassLoader(String resourceName)
static void
readLineByLine(File file, Consumer<String> consumer)
static Map<String,String>
readProperties(String content)
static Map<String,String>
readPropertiesInClassLoader(String path)
static File
resolveJarFile(URL url)
static List<File>
scanFilesystem(File path, FilenameFilter filter)
static List<File>
scanFilesystem(File path, FilenameFilter filter, Predicate<File> directoryFilter)
static void
unzip(File zipFile, File destination)
static void
unzipLogless(File zipFile, File destination)
static void
write(String content, File file)
static void
write(String content, File file, String encoding)
static void
write(String content, String file)
static void
writeToBinary(File file, Serializable data)
-
-
-
Field Detail
-
MEGA
public static final int MEGA
- See Also:
- Constant Field Values
-
DEFAULT_BUFFER_SIZE
public static final int DEFAULT_BUFFER_SIZE
- See Also:
- Constant Field Values
-
-
Method Detail
-
assertFileExists
public static void assertFileExists(File file)
-
assertCanRead
public static void assertCanRead(File file)
-
assertCanWrite
public static void assertCanWrite(File file)
-
assertIsFolder
public static void assertIsFolder(File file)
-
assertIsFile
public static void assertIsFile(File file)
-
getContentLength
public static long getContentLength(File resource)
-
readFileFromClassLoader
public static String readFileFromClassLoader(String resourceName, Charset charset)
-
readFromClassLoader
public static byte[] readFromClassLoader(String resourceName) throws TechnicalException
- Throws:
TechnicalException
-
read
public String read(File file, String encoding) throws IOException
- Throws:
IOException
-
read
public String read(File file) throws IOException
- Throws:
IOException
-
read
public String read(File file, int bufferSize) throws IOException
- Throws:
IOException
-
read
public String read(File file, int bufferSize, String encoding) throws IOException
- Throws:
IOException
-
readLineByLine
public static void readLineByLine(File file, Consumer<String> consumer) throws IOException
- Throws:
IOException
-
readPropertiesInClassLoader
public static Map<String,String> readPropertiesInClassLoader(String path)
-
write
public static void write(String content, String file) throws FilesUtilsException
- Throws:
FilesUtilsException
-
write
public static void write(String content, File file) throws FilesUtilsException
- Throws:
FilesUtilsException
-
write
public static void write(String content, File file, String encoding) throws FilesUtilsException
- Throws:
FilesUtilsException
-
list
public static List<File> list(File folder, FilenameFilter filter)
-
scanFilesystem
public static List<File> scanFilesystem(File path, FilenameFilter filter)
-
scanFilesystem
public static List<File> scanFilesystem(File path, FilenameFilter filter, Predicate<File> directoryFilter)
-
readFromBinary
public static <T extends Serializable> T readFromBinary(File file, T defaultValue)
-
writeToBinary
public static void writeToBinary(File file, Serializable data)
-
isAbsoluteFile
public static boolean isAbsoluteFile(String path)
-
unzip
public static void unzip(File zipFile, File destination) throws IOException
- Throws:
IOException
-
unzipLogless
public static void unzipLogless(File zipFile, File destination) throws IOException
- Throws:
IOException
-
delete
public static boolean delete(File file)
-
readContent
public static String readContent(File file) throws IOException
- Throws:
IOException
-
readBytes
public static byte[] readBytes(File file) throws IOException
- Throws:
IOException
-
getTmpDir
public static File getTmpDir()
-
isWindows
public static boolean isWindows()
-
close
public static void close(Closeable closable)
-
-