use of java.io.FileFilter in project Anki-Android by Ramblurr.
the class Utils method getImportableDecks.
/** Returns a list of apkg-files. */
public static List<File> getImportableDecks() {
String deckPath = AnkiDroidApp.getCurrentAnkiDroidDirectory();
File dir = new File(deckPath);
int deckCount = 0;
File[] deckList = null;
if (dir.exists() && dir.isDirectory()) {
deckList = dir.listFiles(new FileFilter() {
@Override
public boolean accept(File pathname) {
if (pathname.isFile() && pathname.getName().endsWith(".apkg")) {
return true;
}
return false;
}
});
deckCount = deckList.length;
}
List<File> decks = new ArrayList<File>();
for (int i = 0; i < deckCount; i++) {
decks.add(deckList[i]);
}
return decks;
}
use of java.io.FileFilter in project StickerCamera by Skykai521.
the class FileUtils method findPicsInDir.
//获取path路径下的图片
public ArrayList<PhotoItem> findPicsInDir(String path) {
ArrayList<PhotoItem> photos = new ArrayList<PhotoItem>();
File dir = new File(path);
if (dir.exists() && dir.isDirectory()) {
for (File file : dir.listFiles(new FileFilter() {
@Override
public boolean accept(File pathname) {
String filePath = pathname.getAbsolutePath();
return (filePath.endsWith(".png") || filePath.endsWith(".jpg") || filePath.endsWith(".jepg"));
}
})) {
photos.add(new PhotoItem(file.getAbsolutePath(), file.lastModified()));
}
}
Collections.sort(photos);
return photos;
}
use of java.io.FileFilter in project android_frameworks_base by ParanoidAndroid.
the class SQLiteDatabase method deleteDatabase.
/**
* Deletes a database including its journal file and other auxiliary files
* that may have been created by the database engine.
*
* @param file The database file path.
* @return True if the database was successfully deleted.
*/
public static boolean deleteDatabase(File file) {
if (file == null) {
throw new IllegalArgumentException("file must not be null");
}
boolean deleted = false;
deleted |= file.delete();
deleted |= new File(file.getPath() + "-journal").delete();
deleted |= new File(file.getPath() + "-shm").delete();
deleted |= new File(file.getPath() + "-wal").delete();
File dir = file.getParentFile();
if (dir != null) {
final String prefix = file.getName() + "-mj";
final FileFilter filter = new FileFilter() {
@Override
public boolean accept(File candidate) {
return candidate.getName().startsWith(prefix);
}
};
for (File masterJournal : dir.listFiles(filter)) {
deleted |= masterJournal.delete();
}
}
return deleted;
}
use of java.io.FileFilter in project jphp by jphp-compiler.
the class DocGenerator method main.
public static void main(String[] args) throws IOException {
File root = new File(".").getCanonicalFile();
DocGenerator generator = new DocGenerator();
for (File file : root.listFiles(new FileFilter() {
@Override
public boolean accept(File pathname) {
return pathname.isDirectory();
}
})) {
File sdkFile1 = new File(file, "resources/JPHP-INF/sdk/");
File sdkFile2 = new File(file, "src/main/resources/JPHP-INF/sdk/");
if (sdkFile1.isDirectory()) {
generator.addDirectory(sdkFile1, true);
} else if (sdkFile2.isDirectory()) {
generator.addDirectory(sdkFile2, true);
}
}
for (Map.Entry<String, String> entry : languages.entrySet()) {
generator.generate(new File("./docs/api_" + entry.getKey()), entry.getKey());
}
}
use of java.io.FileFilter in project hackpad by dropbox.
the class MozillaSuiteTest method main.
/**
* The main class will run all the test files that are *not* covered in
* the *.tests files, and print out a list of all the tests that pass.
*/
public static void main(String[] args) throws IOException {
PrintStream out = new PrintStream("fix-tests-files.sh");
try {
for (int i = 0; i < OPT_LEVELS.length; i++) {
int optLevel = OPT_LEVELS[i];
File testDir = getTestDir();
File[] allTests = TestUtils.recursiveListFiles(testDir, new FileFilter() {
public boolean accept(File pathname) {
return ShellTest.DIRECTORY_FILTER.accept(pathname) || ShellTest.TEST_FILTER.accept(pathname);
}
});
HashSet<File> diff = new HashSet<File>(Arrays.asList(allTests));
File[] testFiles = getTestFiles(optLevel);
diff.removeAll(Arrays.asList(testFiles));
ArrayList<String> skippedPassed = new ArrayList<String>();
int absolutePathLength = testDir.getAbsolutePath().length() + 1;
for (File testFile : diff) {
try {
(new MozillaSuiteTest(testFile, optLevel)).runMozillaTest();
// strip off testDir
String canonicalized = testFile.getAbsolutePath().substring(absolutePathLength);
canonicalized = canonicalized.replace('\\', '/');
skippedPassed.add(canonicalized);
} catch (Throwable t) {
// failed, so skip
}
}
// appropriate *.tests file.
if (skippedPassed.size() > 0) {
out.println("cat >> " + getTestFilename(optLevel) + " <<EOF");
String[] sorted = skippedPassed.toArray(new String[0]);
Arrays.sort(sorted);
for (int j = 0; j < sorted.length; j++) {
out.println(sorted[j]);
}
out.println("EOF");
}
}
System.out.println("Done.");
} finally {
out.close();
}
}
Aggregations