public class CityParser {
public static final String strR ="ЙЦУКЕНГШЩЗХЪФЫВАПРОЛДЖЭЯЧСМИТЬБЮйцукенгшщзхъфывапролджэячсмитьбю";
public static final String strE ="QWERTYUIOP[]ASDFGHJKL;'ZXCVBNM,.qwertyuiop[]asdfghjkl;'zxcvbnm,.";
public static final char[][] chr = new char[strR.length() + 1][2];
static {
for (int i = 0; i < strR.length(); i++) {
chr[i][0] = strR.charAt(i);
chr[i][1] = strE.charAt(i);
}
}
public static String getChar(String str){
StringBuilder sb = new StringBuilder();
int l = str.length();
for (int i = 0 ; i< l ;i++) {
char ch = str.charAt(i);
for (char[] cs : chr) {
if(cs[0] == ch){
sb.append(cs[1]);
break;
}
}
}
return sb.toString();
}
public static void main(String[] args) throws FileNotFoundException, IOException {
URL url = CityParser.class.getResource("city.log");
File file = new File(url.getFile());
Scanner scanner = new Scanner(file);
while(scanner.hasNextLine()){
String rcity = scanner.nextLine().trim();
String ecity = getChar(rcity);
if(ecity.length()>7 && ecity.contains(".")){
System.out.println(rcity + " - " + ecity);
}
}
}
}
* This source code was highlighted with Source Code Highlighter.| Комментировать | « Пред. запись — К дневнику — След. запись » | Страницы: [1] [Новые] |