Class FileUtils
-
- All Implemented Interfaces:
public class FileUtils
Peli
paulburke (ipaulpro)
-
-
Method Summary
Modifier and Type Method Description static boolean
isExternalStorageDocument(Uri uri)
static boolean
isDownloadsDocument(Uri uri)
static boolean
isMediaDocument(Uri uri)
static boolean
isGooglePhotosUri(Uri uri)
static String
getDataColumn(Context context, Uri uri, String selection, Array<String> selectionArgs)
Get the value of the data column for this Uri. static String
getPath(Context context, Uri uri)
Get a file path from a Uri. static boolean
isGifForSuffix(String suffix)
static boolean
isGif(String mimeType)
是否是gif static boolean
isHttp(String path)
是否是网络图片 static boolean
copyFile(FileInputStream fileInputStream, String outFilePath)
Copies one file into the other with the given paths. static String
extSuffix(InputStream input)
static String
getCreateFileName(String prefix)
根据时间戳创建文件名 -
-
Method Detail
-
isExternalStorageDocument
static boolean isExternalStorageDocument(Uri uri)
- Parameters:
uri
- The Uri to check.- Returns:
Whether the Uri authority is ExternalStorageProvider.
-
isDownloadsDocument
static boolean isDownloadsDocument(Uri uri)
- Parameters:
uri
- The Uri to check.- Returns:
Whether the Uri authority is DownloadsProvider.
-
isMediaDocument
static boolean isMediaDocument(Uri uri)
- Parameters:
uri
- The Uri to check.- Returns:
Whether the Uri authority is MediaProvider.
-
isGooglePhotosUri
static boolean isGooglePhotosUri(Uri uri)
- Parameters:
uri
- The Uri to check.- Returns:
Whether the Uri authority is Google Photos.
-
getDataColumn
static String getDataColumn(Context context, Uri uri, String selection, Array<String> selectionArgs)
Get the value of the data column for this Uri. This is useful for MediaStore Uris, and other file-based ContentProviders.
- Parameters:
context
- The context.uri
- The Uri to query.selection
- (Optional) Filter used in the query.selectionArgs
- (Optional) Selection arguments used in the query.- Returns:
The value of the _data column, which is typically a file path.
-
getPath
static String getPath(Context context, Uri uri)
Get a file path from a Uri. This will get the the path for Storage Access Framework Documents, as well as the _data field for the MediaStore and other file-based ContentProviders. Callers should check whether the path is local before assuming it represents a local file.
- Parameters:
context
- The context.uri
- The Uri to query.
-
isGifForSuffix
static boolean isGifForSuffix(String suffix)
-
isGif
static boolean isGif(String mimeType)
是否是gif
-
isHttp
static boolean isHttp(String path)
是否是网络图片
-
copyFile
static boolean copyFile(FileInputStream fileInputStream, String outFilePath)
Copies one file into the other with the given paths. In the event that the paths are the same, trying to copy one file to the other will cause both files to become null. Simply skipping this step if the paths are identical.
-
extSuffix
static String extSuffix(InputStream input)
-
getCreateFileName
static String getCreateFileName(String prefix)
根据时间戳创建文件名
- Parameters:
prefix
- 前缀名
-
-
-
-