import javaio*;//导入操作要用到的类 public class main { public static void main(String args[]) { File file = new File(c:/testtxt);// 源文件位置 FileReader fr; try { fr = new FileReader(file); BufferedReader in = new BufferedReader(fr);// 包装文件输入流可整行读取 String line; try { while ((line = inreadLine()) != null) { String a = pinyin(line); int shengdiaoLetter = IntegerparseInt(asubstring( alength() alength())); a = asubstring( alength() ) + + asubstring(shengdiaoLetter shengdiaoLetter + ); Systemoutprintln(a); } } catch (IOException e) { // TODO Autogenerated catch block eprintStackTrace(); } } catch (FileNotFoundException e) { // TODO Autogenerated catch block eprintStackTrace(); }// 创建文件输入流 } private static String pinyin(String input) { int position = ; int onlyaeiou = ; input = inputtoLowerCase(); // 单个韵母不必说 (单个的韵母当然就标它上面了) if (ntains(a)) { onlyaeiou++; } if (ntains(e)) { onlyaeiou++; } if (ntains(i)) { onlyaeiou++; } if (ntains(o)) { onlyaeiou++; } if (ntains(u)) { onlyaeiou++; } if (ntains(v)) { onlyaeiou++; } if (onlyaeiou == ) { if (ntains(a)) { position = inputindexOf(a); } if (ntains(e)) { position = inputindexOf(e); } if (ntains(i)) { position = inputindexOf(i); } if (ntains(o)) { position = inputindexOf(o); } if (ntains(u)) { position = inputindexOf(u); } if (ntains(v)) { position = inputindexOf(v); } return input + position; } if (ntains(a)) { position = inputindexOf(a); return input + position; } // 没有a母找o e else if (ntains(o)) { position = inputindexOf(o); return input + position; } else if (ntains(e)) { position = inputindexOf(e); return input + position; } // iu 并列标在后 if (ntains(iu)) { position = inputindexOf(iu) + ; return input + position; } if (ntains(a)) { position = inputindexOf(a); return input + position; } if (ntains(e)) { position = inputindexOf(e); return input + position; } if (ntains(i)) { position = inputindexOf(i); return input + position; } if (ntains(o)) { position = inputindexOf(o); return input + position; } if (ntains(u)) { position = inputindexOf(u); return input + position; } if (ntains(v)) { position = inputindexOf(v); return input + position; } return input; } } 更多更全的java资讯尽在博洋教育有关福州软件培训的任何疑问欢迎咨询在线老师 |