Java Path File Name nio getPathByFilename(String filename, List files)

Here you can find the source of getPathByFilename(String filename, List files)

Description

Find a file by it's filename.

License

Open Source License

Parameter

Parameter Description
filename the filename.extension to search.
files the list of files to search in.

Return

the Path to the file on success, null else.

Declaration

public static Path getPathByFilename(String filename, List<Path> files) 

Method Source Code

//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;
    }
}

Related

  1. getPath(File dir, String filename)
  2. getPath(final String fullFileName)
  3. getPath(Object name)
  4. getPath(String dirName, String fileName)
  5. getPathByClassName(Class clazz, String relativeDir)
  6. getPathByFormat(String nameBeforeDot, String nameAfterDot, Path parent, int i, String date)
  7. getPathCleanName(Path object)
  8. getPathInTmpDir(String fileName)
  9. GetPathName(String path)