public class FileUtil
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
combinePaths(java.lang.String... varargs)
Combine paths
|
static byte[] |
createChecksum(java.lang.String filename)
see this How-to for a faster way to convert
a byte array to a HEX string
|
static boolean |
fileExists(java.lang.String path)
Check if file exists
|
static boolean |
folderExists(java.lang.String path)
Check if folder exists
|
static java.lang.String |
getExternalCacheFolder(android.content.Context context)
Get external cache folder from sd card
|
static java.lang.String |
getExternalFileFolder(android.content.Context context)
Get external file folder from sd card
|
static java.lang.String |
getFolderPath(java.lang.String path)
Get parent folder absolute path
|
static java.lang.String |
getInternalCacheFolder(android.content.Context context)
Get internal cache folder from sd card
|
static java.lang.String |
getInternalFileFolder(android.content.Context context)
Get internal file folder from sd card
|
static java.lang.String |
getMD5Checksum(java.lang.String filename)
see this How-to for a faster way to convert
a byte array to a HEX string
|
static java.util.ArrayList<java.io.File> |
listAllFiles(java.io.File file,
boolean includeFolder)
list all files
|
static java.util.ArrayList<java.lang.String> |
readLinesFromFile(java.io.File file)
read lines from file
|
static java.lang.String |
readTextFromFile(java.io.File file) |
static void |
safeCreateFolder(java.lang.String path)
Create folder if not exists
If the target is a file, remove it and then create folder.
|
public static boolean fileExists(java.lang.String path)
path
- file pathpublic static boolean folderExists(java.lang.String path)
path
- folder pathpublic static java.lang.String getFolderPath(java.lang.String path)
path
- file pathpublic static void safeCreateFolder(java.lang.String path)
If the target is a file, remove it and then create folder.
path
- folder pathpublic static java.lang.String getInternalCacheFolder(android.content.Context context)
context
- android contextpublic static java.lang.String getExternalCacheFolder(android.content.Context context)
context
- android contextpublic static java.lang.String getInternalFileFolder(android.content.Context context)
context
- android contextpublic static java.lang.String getExternalFileFolder(android.content.Context context)
context
- android contextpublic static java.lang.String combinePaths(java.lang.String... varargs)
varargs
- path listpublic static byte[] createChecksum(java.lang.String filename) throws java.lang.Exception
filename
- file namejava.lang.Exception
public static java.lang.String getMD5Checksum(java.lang.String filename)
filename
- file namepublic static java.util.ArrayList<java.io.File> listAllFiles(java.io.File file, boolean includeFolder)
file
- file folderincludeFolder
- includeFolderpublic static java.util.ArrayList<java.lang.String> readLinesFromFile(java.io.File file)
file
- filepublic static java.lang.String readTextFromFile(java.io.File file)