List of usage examples for java.io File list
public String[] list()
From source file:com.aspose.email.examples.outlook.pst.SplitAndMergePSTFile.java
public static void deleteAllOutputFiles() { File dir = new File(dataDir); for (String s : dir.list()) { if (s.startsWith("Test_part") || s.startsWith("Personal folders_part")) { File file = new File(dir.getPath(), s); file.delete();/*from w ww . j av a2s . c o m*/ } } }
From source file:forge.ai.AiProfileUtil.java
/** * Returns an array of strings containing all available profiles. * @return ArrayList<String> - an array of strings containing all * available profiles.// ww w. ja v a 2 s .co m */ public static List<String> getAvailableProfiles() { final List<String> availableProfiles = new ArrayList<String>(); final File dir = new File(AI_PROFILE_DIR); final String[] children = dir.list(); if (children == null) { System.err.println("AIProfile > can't find AI profile directory!"); } else { for (int i = 0; i < children.length; i++) { if (children[i].endsWith(AI_PROFILE_EXT)) { availableProfiles.add(children[i].substring(0, children[i].length() - AI_PROFILE_EXT.length())); } } } return availableProfiles; }
From source file:com.joshlong.esb.springintegration.modules.net.sftp.Main.java
static void run(SFTPSessionFactory sftpSessionFactory, String lp, String rp) throws Throwable { // local path File local = new File(lp); // obviously this is just for test. Do what you need to do in your own // we are testing, after all if (local.exists() && (local.list().length > 0)) { for (File f : local.listFiles()) { if (!f.delete()) { logger.debug("couldn't delete " + f.getAbsolutePath()); }//from w w w. j a v a 2 s . co m } } Resource localDirectory = new FileSystemResource(local); // pool QueuedSFTPSessionPool queuedSFTPSessionPool = new QueuedSFTPSessionPool(sftpSessionFactory); queuedSFTPSessionPool.afterPropertiesSet(); ThreadPoolTaskScheduler taskScheduler = new ThreadPoolTaskScheduler(); taskScheduler.setPoolSize(10); taskScheduler.setErrorHandler(new ErrorHandler() { public void handleError(Throwable t) { logger.debug("error! ", t); } }); taskScheduler.setWaitForTasksToCompleteOnShutdown(true); taskScheduler.initialize(); // synchronizer final SFTPInboundSynchronizer sftpInboundSynchronizer = new SFTPInboundSynchronizer(); sftpInboundSynchronizer.setLocalDirectory(localDirectory); sftpInboundSynchronizer.setRemotePath(rp); sftpInboundSynchronizer.setAutoCreatePath(true); sftpInboundSynchronizer.setPool(queuedSFTPSessionPool); sftpInboundSynchronizer.setShouldDeleteDownloadedRemoteFiles(false); sftpInboundSynchronizer.setTaskScheduler(taskScheduler); sftpInboundSynchronizer.afterPropertiesSet(); sftpInboundSynchronizer.start(); /* new Thread(new Runnable() { public void run() { try { Thread.sleep(60 * 1000); // 1 minute sftpInboundSynchronizer.stop(); } catch (InterruptedException e) { // don't care } } }).start(); */ }
From source file:com.photon.phresco.framework.win8.util.Win8MetroCofigFileParser.java
public static void visitAllDirsAndFiles(File dir, ApplicationInfo info) { if (dir.isDirectory()) { String[] children = dir.list(); for (int i = 0; i < children.length; i++) { File replacePath = replacePath(children[i], dir, info); visitAllDirsAndFiles(replacePath, info); }/* ww w .j a v a2s .c o m*/ } }
From source file:com.sharinglabs.cordova.plugin.cache.Cache.java
private static boolean deleteDir(File dir) { Log.i(LOG_TAG, "Deleting: " + dir.getAbsolutePath()); if (dir != null && dir.isDirectory()) { String[] children = dir.list(); for (int i = 0; i < children.length; i++) { boolean success = deleteDir(new File(dir, children[i])); if (!success) { return false; }/*w w w . j a v a 2 s. c o m*/ } } return dir.delete(); }
From source file:com.github.ipaas.ifw.front.rewrite.FisRewrite.java
private static void initAll() throws FisException { String configDirPath = FisRewrite.class.getClassLoader().getResource(DEFAULT_SERVER_CONFIG_DIR).getFile(); File serverJsonDir = new File(configDirPath); String[] serverJsonFiles = serverJsonDir.list(); FilenameFilter defaultFileNameFilter = new FilenameFilter() { public boolean accept(File dir, String name) { boolean isMatch = name.equals(DEFAULT_SERVER_CONFIG_FILE); return isMatch; }/*from w w w. j a v a 2 s . c o m*/ }; FilenameFilter nameSpaceFileNameFilter = new FilenameFilter() { public boolean accept(File dir, String name) { boolean isMatch = name.endsWith("-" + DEFAULT_SERVER_CONFIG_FILE); return isMatch; } }; String[] childrenFileNames = serverJsonDir.list(defaultFileNameFilter); String[] nameSpacechildrenFileNames = serverJsonDir.list(nameSpaceFileNameFilter); if ((null == childrenFileNames || 0 == childrenFileNames.length) && (null == nameSpacechildrenFileNames || 0 == nameSpacechildrenFileNames.length)) { throw new FisException("server config File server.json Not Found!"); } // ? if (null != childrenFileNames || 0 < childrenFileNames.length) { for (int i = 0; i < childrenFileNames.length; i++) { FisRewrite.init(childrenFileNames[i]); } } // ??? if (null != nameSpacechildrenFileNames || 0 < nameSpacechildrenFileNames.length) { for (int i = 0; i < nameSpacechildrenFileNames.length; i++) { FisRewrite.init(nameSpacechildrenFileNames[i]); } } // for (int i = 0, len = mapJsonFiles.length; i < len; i++) { // String fileName = mapJsonFiles[i]; // if (fileName.equals(FisResource.DEFAULT_RES_MAPPING_FILE)) { // FisResource.register(FisResource.DEFAULT_MAPPING_FILE_DIR, // FisResource.DEFAULT_NS_GLOBAL); // } else { // int pos = fileName.indexOf("-" + // FisResource.DEFAULT_RES_MAPPING_FILE); // if (pos > 0) { // String namespace = fileName.substring(0, pos); // FisResource.register(FisResource.DEFAULT_MAPPING_FILE_DIR, // namespace); // } // } // } }
From source file:Main.java
public static boolean deleteFileRecursively(String path) { File destFile = new File(path); if (!destFile.exists()) { return true; }/* ww w .j a v a 2 s. c o m*/ if (destFile.isFile()) { destFile.delete(); return true; } String[] childNames = destFile.list(); for (String child : childNames) { if (!deleteFileRecursively(new File(path, child).getAbsolutePath())) { return false; } } return destFile.delete(); }
From source file:be.ac.ua.comp.scarletnebula.core.KeyManager.java
static public Collection<String> getKeyNames(final String providerName) { final File dirFile = assureDirectory(providerName); final Collection<String> keynames = new ArrayList<String>(); for (final String keyfile : dirFile.list()) { keynames.add(keyfile.replaceAll("\\.key$", "")); }//from w ww . j av a 2s . c om return keynames; }
From source file:org.meshpoint.anode.util.ModuleUtils.java
private static boolean copyDir(File src, File dest) { dest.mkdir();//from w ww . j a v a 2 s . c om for (String child : src.list()) { boolean result = copyFile(new File(src, child), new File(dest, child)); if (!result) { return false; } } return true; }
From source file:com.eatnumber1.util.io.FileUtils.java
public static boolean isEmpty(@NotNull File file) { if (!file.isDirectory()) throw new IllegalArgumentException("File is not a directory."); return file.list().length == 0; }