import java.io.File; import java.io.IOException; public class Main { public static boolean isFilenameValid(String file) { File f = new File(file); try { f.getCanonicalPath(); return true; } catch (IOException e) { return false; } } public static void main(String args[]) throws Exception { // true System.out.println(FileUtils.isFilenameValid("asdf.txt")); //false System.out.println(FileUtils.isFilenameValid("test.T*T")); } }