Here you can find the source of listFiles(final String directory, final boolean root)
Parameter | Description |
---|---|
directory | the directory to iterate |
private static List<String> listFiles(final String directory, final boolean root)
//package com.java2s; import java.io.File; import java.util.ArrayList; import java.util.List; public class Main { /**// ww w .j a v a 2 s . c om * * @param directory the directory to iterate * @param if the file is a directory (first time it's called must be true) * @return */ private static List<String> listFiles(final String directory, final boolean root) { final File file = new File(directory); final List<String> files = new ArrayList<String>(); if (root) { files.add(directory); } final File[] tabFiles = file.listFiles(); for (File f : tabFiles) { files.add(f.toString()); if (f.isDirectory()) { files.addAll(listFiles(f.toString(), false)); } } return files; } }