Here you can find the source of list(final Path directory)
Parameter | Description |
---|---|
directory | The directory to list the entries for |
public static List<Path> list(final Path directory) throws IOException
//package com.java2s; /*/* w w w .j a v a2 s . co m*/ * eXist Open Source Native XML Database * Copyright (C) 2001-2015 The eXist Project * http://exist-db.org * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software Foundation * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import java.io.IOException; import java.nio.file.*; import java.util.*; import java.util.function.Predicate; import java.util.stream.Collectors; import java.util.stream.Stream; public class Main { /** * A list of the entries in the directory. The listing is not recursive. * * @param directory The directory to list the entries for * * @return The list of entries */ public static List<Path> list(final Path directory) throws IOException { try (final Stream<Path> entries = Files.list(directory)) { return entries.collect(Collectors.toList()); } } /** * A list of the entries in the directory. The listing is not recursive. * * @param directory The directory to list the entries for * @param filter A filter to be applied to the list * @return The list of entries */ public static List<Path> list(final Path directory, final Predicate<Path> filter) throws IOException { try (final Stream<Path> entries = Files.list(directory).filter(filter)) { return entries.collect(Collectors.toList()); } } }