Here you can find the source of getPathByFilename(String filename, List
Parameter | Description |
---|---|
filename | the filename.extension to search. |
files | the list of files to search in. |
public static Path getPathByFilename(String filename, List<Path> files)
//package com.java2s; import java.nio.file.Path; import java.util.List; public class Main { /**/*from ww w. j av a2 s. c o m*/ * Find a file by it's filename. * @param filename the filename.extension to search. * @param files the list of files to search in. * @return the Path to the file on success, null else. */ public static Path getPathByFilename(String filename, List<Path> files) { for (Path file : files) { Path fname = file.getFileName(); if (fname != null && fname.toString().equals(filename)) { return file; } } return null; } }