本文整理汇总了Java中io.vov.vitamio.utils.FileUtils类的典型用法代码示例。如果您正苦于以下问题:Java FileUtils类的具体用法?Java FileUtils怎么用?Java FileUtils使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
FileUtils类属于io.vov.vitamio.utils包,在下文中一共展示了FileUtils类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setDataSource
import io.vov.vitamio.utils.FileUtils; //导入依赖的package包/类
public void setDataSource(Context context, Uri uri) throws IOException, IllegalArgumentException,
SecurityException, IllegalStateException {
if (context == null || uri == null)
throw new IllegalArgumentException();
String scheme = uri.getScheme();
if (scheme == null || scheme.equals("file")) {
setDataSource(FileUtils.getPath(uri.toString()));
return;
}
try {
ContentResolver resolver = context.getContentResolver();
mFD = resolver.openAssetFileDescriptor(uri, "r");
if (mFD == null)
return;
setDataSource(mFD.getParcelFileDescriptor().getFileDescriptor());
return;
} catch (Exception e) {
closeFD();
}
Log.e("Couldn't open file on client side, trying server side %s", uri.toString());
setDataSource(uri.toString());
return;
}
示例2: setDataSource
import io.vov.vitamio.utils.FileUtils; //导入依赖的package包/类
public void setDataSource(Context context, Uri uri, Map<String, String> headers) throws IOException, IllegalArgumentException, SecurityException, IllegalStateException {
if (context == null || uri == null)
throw new IllegalArgumentException();
String scheme = uri.getScheme();
if (scheme == null || scheme.equals("file")) {
setDataSource(FileUtils.getPath(uri.toString()));
return;
}
try {
ContentResolver resolver = context.getContentResolver();
mFD = resolver.openAssetFileDescriptor(uri, "r");
if (mFD == null)
return;
setDataSource(mFD.getParcelFileDescriptor().getFileDescriptor());
return;
} catch (Exception e) {
closeFD();
}
setDataSource(uri.toString(), headers);
}
示例3: setDataSource
import io.vov.vitamio.utils.FileUtils; //导入依赖的package包/类
public void setDataSource(Context context, Uri uri, Map<String, String> headers) throws IOException, IllegalArgumentException, SecurityException, IllegalStateException {
if (context == null || uri == null)
throw new IllegalArgumentException();
String scheme = uri.getScheme();
if (scheme == null || scheme.equals("file")) {
setDataSource(FileUtils.getPath(uri.toString()));
return;
}
try {
ContentResolver resolver = context.getContentResolver();
mFD = resolver.openAssetFileDescriptor(uri, "r");
if (mFD == null)
return;
setDataSource(mFD.getParcelFileDescriptor().getFileDescriptor());
return;
} catch (Exception e) {
closeFD();
}
setDataSource(uri.toString(), headers);
}
示例4: setDataSource
import io.vov.vitamio.utils.FileUtils; //导入依赖的package包/类
public void setDataSource(Context context, Uri uri) throws IOException, IllegalArgumentException,
SecurityException, IllegalStateException {
if (context == null || uri == null)
throw new IllegalArgumentException();
String scheme = uri.getScheme();
if (scheme == null || scheme.equals("file")) {
setDataSource(FileUtils.getPath(uri.toString()));
return;
}
try {
ContentResolver resolver = context.getContentResolver();
mFD = resolver.openAssetFileDescriptor(uri, "r");
if (mFD == null)
return;
setDataSource(mFD.getParcelFileDescriptor().getFileDescriptor());
return;
} catch (Exception e) {
closeFD();
}
Log.e("Couldn't open file on client side, trying server side %s", uri.toString());
setDataSource(uri.toString());
return;
}
示例5: prescan
import io.vov.vitamio.utils.FileUtils; //导入依赖的package包/类
private void prescan(String filePath) throws RemoteException {
mProvider = mContext.getContentResolver().acquireContentProviderClient(MediaStore.AUTHORITY);
Cursor c = null;
String where = null;
String[] selectionArgs = null;
if (mFileCache == null)
mFileCache = new HashMap<String, FileCacheEntry>();
else
mFileCache.clear();
try {
if (filePath != null) {
where = Video.Media.DATA + "=?";
selectionArgs = new String[]{filePath};
}
c = mProvider.query(Video.Media.CONTENT_URI, VIDEO_PROJECTION, where, selectionArgs, null);
if (c != null) {
try {
while (c.moveToNext()) {
long rowId = c.getLong(ID_VIDEO_COLUMN_INDEX);
String path = c.getString(PATH_VIDEO_COLUMN_INDEX);
long lastModified = c.getLong(DATE_MODIFIED_VIDEO_COLUMN_INDEX);
if (path.startsWith("/")) {
File tempFile = new File(path);
if (!TextUtils.isEmpty(filePath) && !tempFile.exists()) {
mProvider.delete(Video.Media.CONTENT_URI, where, selectionArgs);
return;
}
path = FileUtils.getCanonical(tempFile);
String key = mCaseInsensitivePaths ? path.toLowerCase() : path;
mFileCache.put(key, new FileCacheEntry(Video.Media.CONTENT_URI, rowId, path, lastModified));
}
}
} finally {
c.close();
c = null;
}
}
} finally {
if (c != null) {
c.close();
}
}
}
示例6: prescan
import io.vov.vitamio.utils.FileUtils; //导入依赖的package包/类
private void prescan(String filePath) throws RemoteException {
mProvider = mContext.getContentResolver().acquireContentProviderClient(MediaStore.AUTHORITY);
Cursor c = null;
String where = null;
String[] selectionArgs = null;
if (mFileCache == null)
mFileCache = new HashMap<String, FileCacheEntry>();
else
mFileCache.clear();
try {
if (filePath != null) {
where = Video.Media.DATA + "=?";
selectionArgs = new String[]{filePath};
}
c = mProvider.query(Video.Media.CONTENT_URI, VIDEO_PROJECTION, where, selectionArgs, null);
if (c != null) {
try {
while (c.moveToNext()) {
long rowId = c.getLong(ID_VIDEO_COLUMN_INDEX);
String path = c.getString(PATH_VIDEO_COLUMN_INDEX);
long lastModified = c.getLong(DATE_MODIFIED_VIDEO_COLUMN_INDEX);
if (path.startsWith("/")) {
File tempFile = new File(path);
if (!TextUtils.isEmpty(filePath) && !tempFile.exists()) {
mProvider.delete(Video.Media.CONTENT_URI, where, selectionArgs);
return;
}
path = FileUtils.getCanonical(tempFile);
String key = mCaseInsensitivePaths ? path.toLowerCase() : path;
mFileCache.put(key, new FileCacheEntry(Video.Media.CONTENT_URI, rowId, path, lastModified));
}
}
} finally {
c.close();
c = null;
}
}
} finally {
if (c != null) {
c.close();
}
}
}