Here you can find the source of asPathsList(final File[] files)
Parameter | Description |
---|---|
files | An array of java.io.File |
public static List<Path> asPathsList(final File[] files)
//package com.java2s; /*/* w ww .j a v a2s . 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.File; import java.nio.file.*; import java.util.*; import java.util.stream.Collectors; public class Main { /** * Convert an array of {@link java.io.File} * to a List of {@link java.nio.file.Path} * * @param files An array of {@link java.io.File} * * @return If files is null or empty, then * an empty list, otherwise a list of corresponding * {@link java.nio.file.Path} */ public static List<Path> asPathsList(final File[] files) { return Optional.ofNullable(files) .map(fs -> Arrays.stream(fs).map(File::toPath).collect(Collectors.toList())) .orElse(Collections.EMPTY_LIST); } }