2 *
\83t
\83@
\83C
\83\8b\82É
\8aÖ
\82·
\82é
\83\86\81[
\83e
\83B
\83\8a\83e
\83B
7 import java.util.regex.Pattern;
13 public class FileUtil {
14 private static Pattern safeFileName_SPACE = Pattern.compile(" {2}+");
15 public static String safeFileName(String str) {
16 //
\8eÀ
\91Ì
\8eQ
\8fÆ
\82Ì
\83p
\81[
\83X
19 StringBuffer sb = new StringBuffer();
21 while((new_index = str.indexOf("&#",old_index)) >= 0){
22 sb.append(str,old_index,new_index);
23 old_index = str.indexOf(";",new_index);
24 ch = str.substring(new_index+2,old_index);
25 sb.append(new String(new char[]{(char) Integer.parseInt(ch)}));
28 //
\8dÅ
\8cã
\82É
\92Ç
\89Á
29 sb.append(str,old_index,str.length());
31 //
\83t
\83@
\83C
\83\8b\83V
\83X
\83e
\83\80\82Å
\88µ
\82¦
\82é
\8c`
\82É
32 str = str.replace('/', '
\81^');
33 str = str.replace('\\', '
\81\8f');
34 str = str.replace('?', '
\81H');
35 str = str.replace('*', '
\81\96');
36 str = str.replace(':', '
\81F');
37 str = str.replace('|', '
\81b');
38 str = str.replace('\"', '
\81h');
39 str = str.replace('<', '
\81\83');
40 str = str.replace('>', '
\81\84');
41 str = str.replace('.', '
\81D');
42 str = safeFileName_SPACE.matcher(str).replaceAll(" ");