Here you can find the source of cleanFileName(String badFileName)
public static String cleanFileName(String badFileName)
//package com.java2s; public class Main { /**/*from ww w. j a v a2 s.c om*/ * Conservative approach to insuring that a given filename only contains characters that are legal for use in filenames on the disk. Other * characters are replaced with _ . */ public static String cleanFileName(String badFileName) { StringBuilder cleanName = new StringBuilder(); for (int i = 0; i < badFileName.length(); i++) { int c = (int) badFileName.charAt(i); if (Character.isJavaIdentifierPart(c)) cleanName.append((char) c); else cleanName.append('_'); } return cleanName.toString(); } }