Here you can find the source of findByFileName(List
public static File findByFileName(List<File> files, String fileName) throws FileNotFoundException
//package com.java2s; /*/*ww w . jav a2s . c om*/ GNU LESSER GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/> Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. This version of the GNU Lesser General Public License incorporates the terms and conditions of version 3 of the GNU General Public License */ import java.io.File; import java.io.FileNotFoundException; import java.util.List; public class Main { public static File findByFileName(List<File> files, String fileName) throws FileNotFoundException { for (File itFile : files) { if (itFile.getName().equals(fileName)) { return itFile; } } throw new FileNotFoundException("The file name " + fileName + " doesn't exist"); } }