Что ему не нравится?
package com.javarush.task.task19.task1924;
import java.io.*;
import java.util.HashMap;
import java.util.Map;
import static java.lang.Integer.*;
/*
Замена чисел
*/
public class Solution {
public static Map<Integer, String> map = new HashMap();
static {
map.put(0, "ноль");
map.put(1, "один");
map.put(2, "два");
map.put(3, "три");
map.put(4, "четыре");
map.put(5, "пять");
map.put(6, "шесть");
map.put(7, "семь");
map.put(8, "восемь");
map.put(9, "девять");
map.put(10, "десять");
map.put(11, "одиннадцать");
map.put(12, "двенадцать");
}
public static void main(String[] args) {
BufferedReader reader = null;
try {
reader = new BufferedReader(new InputStreamReader(System.in));
String filename = reader.readLine();
File file = new File(filename);
write(file);
} catch (IOException e) {}
finally {
try {
reader.close();
} catch (IOException e) {
}
}
}
private static void write(File file){
BufferedReader reader = null;
FileReader fileReader = null;
try {
fileReader = new FileReader(file);
reader = new BufferedReader(fileReader);
String s = null;
while (true) {
String string = reader.readLine();
if (string == null) break;
String[] line = string.split(" ");
for (int i = 0; i< line.length; i++){
if (line[i].matches("[-+]?\\d+") && map.containsKey(Integer.parseInt(line[i]))){
string = string.replaceFirst(line[i], map.get(Integer.parseInt(line[i])));
}
}
System.out.println(string);
}
} catch (IOException e) {}
finally {
try {
if (reader != null) {
reader.close();
}
if (fileReader != null) {
fileReader.close();
}
} catch (IOException e) {
}
}
}
}