当前位置: 首页>>代码示例>>Java>>正文


Java FileUtils类代码示例

本文整理汇总了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;
}
 
开发者ID:Leavessilent,项目名称:QuanMinTV,代码行数:25,代码来源:MediaMetadataRetriever.java

示例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);
}
 
开发者ID:coding-dream,项目名称:TPlayer,代码行数:22,代码来源:MediaPlayer.java

示例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);
}
 
开发者ID:WangZhiYao,项目名称:VideoDemo,代码行数:22,代码来源:MediaPlayer.java

示例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;
}
 
开发者ID:WangZhiYao,项目名称:VideoDemo,代码行数:25,代码来源:MediaMetadataRetriever.java

示例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();
    }
  }
}
 
开发者ID:coding-dream,项目名称:TPlayer,代码行数:47,代码来源:MediaScanner.java

示例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();
        }
    }
}
 
开发者ID:WangZhiYao,项目名称:VideoDemo,代码行数:47,代码来源:MediaScanner.java


注:本文中的io.vov.vitamio.utils.FileUtils类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。