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() 

Source Link

Document

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

Usage

From source file:com.eatnumber1.util.io.FileUtils.java

public static boolean contains(@NotNull File directory, @NotNull String fileName) {
    return Arrays.asList(directory.list()).contains(fileName);
}

From source file:com.autburst.picture.Utilities.java

public static String[] getAlbums() {
    File file = getAlbumsDirectory();
    String[] list = file.list();
    return list;
}

From source file:eu.annocultor.reports.ReportPresenter.java

public static void generateReport(File annoCultorHome) throws Exception {
    Logger log = LoggerFactory.getLogger("ReportPresenter");
    File dir = new File(annoCultorHome, "doc");
    if (dir.isDirectory() && dir.exists() && dir.list().length > 0) {

        for (File fn : dir.listFiles()) {
            if (fn.isDirectory() && !fn.isHidden()) {
                String datasetId = fn.getName();
                log.info("Loading conversion statistics for " + datasetId);
                ReportPresenter reportPresenter = new ReportPresenter(dir, datasetId);
                log.info("Generating conversion report for " + datasetId);
                reportPresenter.makeHtmlReport();
            }/*from w ww . j av a  2s  . co m*/
        }
    }
}

From source file:Main.java

public static void delAllFiles(File dir) {
    if (!dir.exists() || !dir.isDirectory()) {
        return;/*from  w  ww .j  a v a2s. c  om*/
    }
    String dirFullName = dir.getAbsolutePath();

    String[] fileList = dir.list();
    File tempFile = null;
    for (int i = 0; i < fileList.length; i++) {
        if (dirFullName.endsWith(File.separator)) {
            tempFile = new File(dirFullName + fileList[i]);
        } else {
            tempFile = new File(dirFullName + File.separator + fileList[i]);
        }
        if (tempFile.isFile()) {
            tempFile.delete();
        }
        if (tempFile.isDirectory()) {
            delAllFiles(dirFullName + "/" + fileList[i]);
            delDir(dirFullName + "/" + fileList[i]);
        }
    }
}

From source file:com.khubla.antlr4formatter.Antlr4Formatter.java

/**
 * get a list of all files in a directory
 *//*from  www .j  a  v a 2 s.  c om*/
private static List<String> getFiles(String dir, List<String> files, String filter) throws Exception {
    final File file = new File(dir);
    final String[] list = file.list();
    if (null != list) {
        for (int i = 0; i < list.length; i++) {
            final String fileName = dir + (dir.endsWith("/") ? "" : "/") + list[i];
            final File f2 = new File(fileName);
            if (false == f2.isHidden()) {
                if (f2.isDirectory()) {
                    getFiles(fileName + "/", files, filter);
                } else {
                    if (fileName.endsWith(filter)) {
                        files.add(fileName);
                    }
                }
            }
        }
    }
    return files;
}

From source file:com.autburst.picture.Utilities.java

public static boolean existsAlbumName(String name) {
    File file = getAlbumsDirectory();
    String[] list = file.list();

    for (String file2 : list) {
        if (file2.equals(name))
            return true;
    }/*from w  w w .  j  a v  a 2 s  .  c  o m*/

    return false;
}

From source file:com.autburst.picture.Utilities.java

public static String[] getAlbumsDecoded() {
    File file = getAlbumsDirectory();
    String[] list = file.list();
    for (int i = 0; i < list.length; i++) {
        list[i] = new String(Base64.decodeBase64(list[i].getBytes()));
    }//from ww w . j ava2 s  .  co m

    if (list.length > 1) {
        Arrays.sort(list);
    }
    return list;
}

From source file:com.compomics.pladipus.core.control.util.ZipUtils.java

static private void addFolderToZip(String path, String srcFolder, ZipOutputStream zip)
        throws UnspecifiedPladipusException, IOException {
    File folder = new File(srcFolder);

    for (String fileName : folder.list()) {
        if (path.equals("")) {
            addFileToZip(folder.getName(), srcFolder + "/" + fileName, zip);
        } else {/*  www.  j  a  v a2 s.  c  o m*/
            addFileToZip(path + "/" + folder.getName(), srcFolder + "/" + fileName, zip);
        }
    }
}

From source file:com.autburst.picture.Utilities.java

public static List<String> getAlbumsAsList() {
    List<String> albums = new ArrayList<String>();

    File file = getAlbumsDirectory();
    String[] list = file.list();
    if (list == null) {
        return albums;
    }/*  ww w  . j  a  v a 2 s  . c  om*/
    for (int i = 0; i < list.length; i++) {
        albums.add(list[i]);
    }
    return albums;
}

From source file:com.santiagolizardo.madcommander.util.io.FileOperations.java

public static boolean delete(File file) {
    if (file == null) {
        throw new IllegalArgumentException();
    }/*from w  w w  . j a  v  a  2  s . c om*/

    if (file.isDirectory()) {
        String[] list = file.list();
        for (String child : list) {
            boolean success = delete(new File(file, child));
            if (!success) {
                return false;
            }
        }
    }

    return file.delete();
}