Java tutorial
//package com.java2s; import java.io.File; import java.util.Collection; public class Main { public static void addPluginIfMatches(File folderOrJar, String bundleName, Collection<File> result) { String name = folderOrJar.getName(); if (folderOrJar.isFile()) { if (name.equals(bundleName + ".jar") || name.startsWith(bundleName + "_") && name.endsWith(".jar")) result.add(folderOrJar); } else { if (name.equals(bundleName) || name.startsWith(bundleName + "_")) result.add(folderOrJar); } } }