Here you can find the source of getFileName(String localRootDirName, String ending)
public static String getFileName(String localRootDirName, String ending)
//package com.java2s; /*----------------------------------------------------------------------------- * vlsSMLM Software/* ww w. j ava 2 s.c om*/ * * Copyright (C) 2014 Matthieu Palayret * Department of Chemistry * University of Cambridge, UK * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. *---------------------------------------------------------------------------*/ import java.io.File; public class Main { public static String getFileName(String localRootDirName, String ending) { File folder = new File(localRootDirName); File[] listOfFiles = folder.listFiles(); // Find the image which name contains such an Ending int i = 0; for (i = 0; i < listOfFiles.length; i++) { if (listOfFiles[i].getName().indexOf(ending) >= 0) break; } if (i == listOfFiles.length) return null; else return listOfFiles[i].getName(); } }