正在阅读:用Java将文件名从中文转为拼音用Java将文件名从中文转为拼音

2004-12-09 10:11 出处:PConline 作者:guoxiaoshou2000 责任编辑:linjixiong


  try
  {
  FileReader fr = new FileReader(f);
  BufferedReader br = new BufferedReader(fr);
  String line = new String("");

  line = br.readLine();
  int count = 0;
  int location = 0;
  while(line != null)
  {
  while(pinyin.indexOf(line.charAt(0)) != -1)
  {
  location = pinyin.indexOf(line.charAt(0));
  pinyin = pinyin.substring(0, location) +
  line.substring(1, 2) +
  pinyin.substring(location + 1, pinyin.length());
  }
  line = br.readLine();
  System.out.print("\b\b\b\b\b\b" + count++);
  }
  fr.close();
  br.close();  
  }
  catch(Exception e)
  {
  //   System.err.println(e);
  }
  return pinyin;
  }
  
  
  public static void main(String[] args)
  {
  
  String paths = new String("D:\\Work\\2004.10.8\\test system\\test01\\word\\");
  String savepaths = new String ("D:\\Work\\2004.10.8\\test system\\test01\\html\\");
  String path = new String("D:\\test\\file\\pinyin.txt");
  
  change(path, paths, savepaths);

  }
  }


  其中拼音和汉字对照得文件可以通过Windows自带得程序获得。

察看评论详细内容 我要发表评论
作者笔名 简短内容 发表时间
:
键盘也能翻页,试试“← →”键

关注我们

最新资讯离线随时看 聊天吐槽赢奖品