Search in sources :

Example 16 with FilenameFilter

use of java.io.FilenameFilter in project android_frameworks_base by ParanoidAndroid.

the class VideoDumpView method onResume.

@Override
public void onResume() {
    Log.d(TAG, "onResume");
    mMediaPlayer = new MediaPlayer();
    try {
        mMediaPlayer.setDataSource(VideoDumpConfig.VIDEO_URI);
        class RGBFilter implements FilenameFilter {

            public boolean accept(File dir, String name) {
                return (name.endsWith(VideoDumpConfig.IMAGE_SUFFIX));
            }
        }
        File dump_dir = new File(VideoDumpConfig.ROOT_DIR);
        File[] dump_files = dump_dir.listFiles(new RGBFilter());
        for (File dump_file : dump_files) {
            dump_file.delete();
        }
        File image_list = new File(VideoDumpConfig.ROOT_DIR + VideoDumpConfig.IMAGES_LIST);
        image_list.delete();
        mImageListWriter = new BufferedWriter(new FileWriter(image_list));
    } catch (java.io.IOException e) {
        Log.e(TAG, e.getMessage(), e);
    }
    queueEvent(new Runnable() {

        public void run() {
            mRenderer.setMediaPlayer(mMediaPlayer);
            mRenderer.setImageListWriter(mImageListWriter);
        }
    });
    super.onResume();
}
Also used : FilenameFilter(java.io.FilenameFilter) FileWriter(java.io.FileWriter) IOException(java.io.IOException) File(java.io.File) MediaPlayer(android.media.MediaPlayer) BufferedWriter(java.io.BufferedWriter)

Example 17 with FilenameFilter

use of java.io.FilenameFilter in project android_frameworks_base by ParanoidAndroid.

the class PackageManagerService method deleteTempPackageFiles.

private void deleteTempPackageFiles() {
    final FilenameFilter filter = new FilenameFilter() {

        public boolean accept(File dir, String name) {
            return name.startsWith("vmdl") && name.endsWith(".tmp");
        }
    };
    deleteTempPackageFilesInDirectory(mAppInstallDir, filter);
    deleteTempPackageFilesInDirectory(mDrmAppPrivateInstallDir, filter);
}
Also used : FilenameFilter(java.io.FilenameFilter) File(java.io.File) ZipFile(java.util.zip.ZipFile)

Example 18 with FilenameFilter

use of java.io.FilenameFilter in project GT by Tencent.

the class LogController method setLastestLogFileAsCurFile.

private void setLastestLogFileAsCurFile() {
    // 遍历日志文件夹中的日志文件,取最新的为当前写目标
    if (!curLogFolder.exists()) {
        curLogFolder.mkdirs();
    }
    // 过滤出合法的日志文件
    File[] files = curLogFolder.listFiles(new FilenameFilter() {

        @Override
        public boolean accept(File dir, String filename) {
            return filename.matches(LogUtils.LOG_FILE_MATCHE);
        }
    });
    // 按修改时间排序
    if (null != files && files.length > 0) {
        Arrays.sort(files, 0, files.length, new Comparator<File>() {

            @Override
            public int compare(File lhs, File rhs) {
                return lhs.lastModified() <= rhs.lastModified() ? 1 : -1;
            }
        });
        // 取最新的文件为当前文件
        curFile = files[0];
    } else {
        curFile = new File(curLogFolder, 00 + LogUtils.LOG_POSFIX);
    }
}
Also used : FilenameFilter(java.io.FilenameFilter) File(java.io.File)

Example 19 with FilenameFilter

use of java.io.FilenameFilter in project GT by Tencent.

the class GTGPSUtils method getGPSFileList.

public static ArrayList<String> getGPSFileList() {
    ArrayList<String> arrFile = new ArrayList<String>();
    try {
        File[] files = Env.ROOT_GPS_FOLDER.listFiles(new FilenameFilter() {

            @Override
            public boolean accept(File dir, String filename) {
                if (filename != null && filename.endsWith(".gps")) {
                    return true;
                }
                return false;
            }
        });
        if (files != null) {
            // 文件个数
            int count = files.length;
            for (int i = 0; i < count; i++) {
                File file = files[i];
                arrFile.add(file.getName());
            }
        } else {
            arrFile.add("empty");
        }
    } catch (Exception ex) {
        ex.printStackTrace();
    }
    return arrFile;
}
Also used : FilenameFilter(java.io.FilenameFilter) ArrayList(java.util.ArrayList) File(java.io.File)

Example 20 with FilenameFilter

use of java.io.FilenameFilter in project ice by Netflix.

the class MapDb method upload.

void upload() {
    AmazonS3Client s3Client = AwsUtils.getAmazonS3Client();
    File dir = new File(config.localDir);
    File[] files = dir.listFiles(new FilenameFilter() {

        public boolean accept(File file, String fileName) {
            return fileName.startsWith(dbName);
        }
    });
    for (File file : files) s3Client.putObject(config.workS3BucketName, config.workS3BucketPrefix + file.getName(), file);
    for (File file : files) s3Client.putObject(config.workS3BucketName, config.workS3BucketPrefix + "copy" + file.getName(), file);
}
Also used : FilenameFilter(java.io.FilenameFilter) AmazonS3Client(com.amazonaws.services.s3.AmazonS3Client) File(java.io.File)

Aggregations

FilenameFilter (java.io.FilenameFilter)354 File (java.io.File)350 IOException (java.io.IOException)87 ArrayList (java.util.ArrayList)61 Test (org.junit.Test)49 URL (java.net.URL)19 RandomAccessFile (java.io.RandomAccessFile)18 List (java.util.List)17 HashSet (java.util.HashSet)15 FileOutputStream (java.io.FileOutputStream)14 MalformedURLException (java.net.MalformedURLException)12 FileFilter (java.io.FileFilter)11 FileNotFoundException (java.io.FileNotFoundException)11 TestClient (org.syncany.tests.util.TestClient)11 FileWriter (java.io.FileWriter)10 HashMap (java.util.HashMap)10 ZipFile (java.util.zip.ZipFile)10 BufferedWriter (java.io.BufferedWriter)9 FileInputStream (java.io.FileInputStream)9 FileReader (java.io.FileReader)9