use of java.io.FilenameFilter in project graphdb by neo4j-attic.
the class DumpLogicalLog method filenamesOf.
private static String[] filenamesOf(String string) {
File file = new File(string);
if (file.isDirectory()) {
File[] files = file.listFiles(new FilenameFilter() {
public boolean accept(File dir, String name) {
return name.contains("_logical.log.v");
}
});
Collection<String> result = new TreeSet<String>();
for (int i = 0; i < files.length; i++) {
result.add(files[i].getPath());
}
return result.toArray(new String[result.size()]);
} else {
return new String[] { string };
}
}
use of java.io.FilenameFilter in project neo4j-mobile-android by neo4j-contrib.
the class DumpLogicalLog method filenamesOf.
protected static String[] filenamesOf(String filenameOrDirectory, final String prefix) {
File file = new File(filenameOrDirectory);
if (file.isDirectory()) {
File[] files = file.listFiles(new FilenameFilter() {
public boolean accept(File dir, String name) {
return name.contains(prefix) && !name.contains("active");
}
});
Collection<String> result = new TreeSet<String>(sequentialComparator());
for (int i = 0; i < files.length; i++) {
result.add(files[i].getPath());
}
return result.toArray(new String[result.size()]);
} else {
return new String[] { filenameOrDirectory };
}
}
use of java.io.FilenameFilter in project graphdb by neo4j-attic.
the class TestXaFramework method testCreateXaResource.
@Test
public void testCreateXaResource() throws Exception {
Map<Object, Object> config = new HashMap<Object, Object>();
config.put("store_dir", "target/var");
config.put(LogBufferFactory.class, CommonFactories.defaultLogBufferFactory(config));
xaDsMgr.registerDataSource("dummy_datasource", new DummyXaDataSource(config), UTF8.encode("DDDDDD"));
XaDataSource xaDs = xaDsMgr.getXaDataSource("dummy_datasource");
DummyXaConnection xaC = null;
try {
xaC = (DummyXaConnection) xaDs.getXaConnection();
try {
xaC.doStuff1();
fail("Non enlisted resource should throw exception");
} catch (XAException e) {
// good
}
Xid xid = new XidImpl(new byte[0], new byte[0]);
xaC.getXaResource().start(xid, XAResource.TMNOFLAGS);
try {
xaC.doStuff1();
xaC.doStuff2();
} catch (XAException e) {
fail("Enlisted resource should not throw exception");
}
xaC.getXaResource().end(xid, XAResource.TMSUCCESS);
xaC.getXaResource().prepare(xid);
xaC.getXaResource().commit(xid, false);
} finally {
xaDsMgr.unregisterDataSource("dummy_datasource");
if (xaC != null) {
xaC.destroy();
}
}
// cleanup dummy resource log
File dir = new File(".");
File[] files = dir.listFiles(new FilenameFilter() {
public boolean accept(File dir, String fileName) {
return fileName.startsWith(resourceFile());
}
});
for (int i = 0; i < files.length; i++) {
files[i].delete();
}
}
use of java.io.FilenameFilter in project pinpoint by naver.
the class AgentDirBaseClassPathResolver method resolvePlugins.
@Override
public URL[] resolvePlugins() {
final File file = new File(getAgentPluginPath());
if (!file.exists()) {
logger.warn(file + " not found");
return new URL[0];
}
if (!file.isDirectory()) {
logger.warn(file + " is not a directory");
return new URL[0];
}
final File[] jars = file.listFiles(new FilenameFilter() {
@Override
public boolean accept(File dir, String name) {
return name.endsWith(".jar");
}
});
if (jars == null || jars.length == 0) {
return new URL[0];
}
final URL[] urls = new URL[jars.length];
for (int i = 0; i < jars.length; i++) {
try {
urls[i] = jars[i].toURI().toURL();
} catch (MalformedURLException e) {
// TODO have to change to PinpointException AFTER moving the exception to pinpoint-common
throw new RuntimeException("Fail to load plugin jars", e);
}
}
for (File pluginJar : jars) {
logger.info("Found plugins: " + pluginJar.getPath());
}
return urls;
}
use of java.io.FilenameFilter in project custom-cert-https by nelenkov.
the class MainActivity method listCertificateFiles.
private static String[] listCertificateFiles() {
File externalStorage = Environment.getExternalStorageDirectory();
FilenameFilter ff = new FilenameFilter() {
@Override
public boolean accept(File dir, String filename) {
if (filename.contains(".")) {
String[] filenameExt = filename.split("\\.");
String ext = filenameExt[filenameExt.length - 1].toLowerCase();
if (ext.equals("cer") || ext.equals("der")) {
return true;
}
}
return false;
}
};
return externalStorage.list(ff);
}
Aggregations