Example usage for java.io File list

List of usage examples for java.io File list

Introduction

In this page you can find the example usage for java.io File list.

Prototype

public String[] list(FilenameFilter filter) 

Source Link

Document

Returns an array of strings naming the files and directories in the directory denoted by this abstract pathname that satisfy the specified filter.

Usage

From source file:com.liusoft.dlog4j.MailTransportQueue.java

/**
 * ?//  w  w  w.j a  va 2 s.  c  o m
 * @return
 */
public int queueSize() {
    File fs = new File(path);
    try {
        return fs.list(fnFilter).length;
    } finally {
        fs = null;
    }
}

From source file:gr.aueb.mipmapgui.controller.file.ActionInitialize.java

private void getSavedUserFiles(String user) {
    JSONArray taskFileArr = new JSONArray();

    ActionCreateUserDirectory actionCreateUserDirectory = new ActionCreateUserDirectory(modello);
    actionCreateUserDirectory.performAction(user);
    ActionCleanDirectory actionCleanDirectory = new ActionCleanDirectory(modello);
    actionCleanDirectory.performAction(user);

    File tasksDir = new File(Costanti.SERVER_MAIN_FOLDER + Costanti.SERVER_FILES_FOLDER + user + "/");
    String[] taskFiles = tasksDir.list(DirectoryFileFilter.INSTANCE);
    for (String file : taskFiles) {
        if (!file.equalsIgnoreCase("temp")) {
            taskFileArr.add(file);/*from w ww . j a va 2 s  .  co  m*/
        }
    }
    JSONObject.put("savedTasks", taskFileArr);
}

From source file:com.aegiswallet.utils.BasicUtils.java

public static String[] loadFileList() {

    String[] fileList = null;// w  ww .  ja  v a2s .  co m
    File filesPath = Constants.WALLET_BACKUP_DIRECTORY;

    if (Constants.WALLET_BACKUP_DIRECTORY.exists() && Constants.WALLET_BACKUP_DIRECTORY.isDirectory()) {
        final String filePrefix = "AegisWalletBackup";
        try {
            filesPath.mkdirs();
        } catch (SecurityException e) {
            Log.e(TAG, "Could not write to SD card - " + e.toString());
        }
        if (filesPath.exists()) {
            FilenameFilter filter = new FilenameFilter() {
                public boolean accept(File dir, String filename) {
                    File sel = new File(dir, filename);
                    return filename.contains(filePrefix) || sel.isDirectory();
                }
            };
            fileList = filesPath.list(filter);
        } else {
            fileList = new String[0];
        }
    }

    return fileList;
}

From source file:com.github.k0zka.contentcompress.ContentGzipMojo.java

void seekAndGzip(final File directory) throws IOException {
    final String[] fileNames = directory.list(new FilesToGzipFilter(minSize, extensions));
    if (fileNames == null) {
        getLog().error("Directory does not exist: " + directory.getAbsolutePath());
        return;/*w  w w.  ja v  a2  s.c o m*/
    }
    for (final String fileName : fileNames) {
        compress(directory, fileName);
    }
    final String[] subDirs = directory.list(new SubdirsFilter());
    for (final String subDir : subDirs) {
        seekAndGzip(new File(directory, subDir));
    }
}

From source file:com.consol.citrus.admin.util.FileHelperImpl.java

/**
 * {@inheritDoc}//from  w  w w  .  jav a2  s .  c  o m
 */
public String[] getFolders(File directory) {
    if (directory.exists()) {
        String[] files = directory.list(new FilenameFilter() {
            public boolean accept(File dir, String name) {
                return name.charAt(0) != '.' && new File(dir, name).isDirectory();
            }
        });

        if (files != null) {
            Arrays.sort(files, String.CASE_INSENSITIVE_ORDER);
            return files;
        } else {
            return new String[] {};
        }
    } else {
        throw new CitrusAdminRuntimeException(
                "Could not open directory because it does not exist: " + directory);
    }
}

From source file:net.scran24.admin.server.services.SurveyManagementServiceImpl.java

@Override
public List<String> listSurveys() {
    File dir = new File(getServletContext().getRealPath("/surveys"));
    return Arrays.asList(dir.list(new FilenameFilter() {
        @Override//from ww  w  .  j a va  2 s.c  om
        public boolean accept(File f, String n) {
            return f.isDirectory();
        }
    }));
}