Here you can find the source of isValidFileName(String fileName)
public static boolean isValidFileName(String fileName)
//package com.java2s; import java.io.File; import java.io.IOException; public class Main { private static final char[] ILLEGAL_CHARACTERS = { '`', '?', '*', '\\', '<', '>', '|', '\"', ':', '/', '\n', '\r', '\t', '\0', '\f' }; public static boolean isValidFileName(String fileName) { if (fileName == null || fileName.length() == 0) { return false; }// w w w.ja va 2 s . c om for (char c : ILLEGAL_CHARACTERS) { if (fileName.indexOf(c) != -1) { return false; } } File f = new File(fileName); try { f.getCanonicalPath(); return true; } catch (IOException e) { return false; } } }