Не могу понять, что не так. Не проходит 6ой пункт. Решал двумя способами, всё без результатно.
package com.javarush.task.task19.task1924;
import java.io.*;
import java.util.HashMap;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/*
Замена чисел
*/
public class Solution {
public static Map<Integer, String> map = new HashMap<Integer, String>();
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 = new BufferedReader(new InputStreamReader(System.in));
String file = null;
try {
file = reader.readLine();
reader.close();
} catch (IOException e) {
e.printStackTrace();
}
try (BufferedReader readerFile = new BufferedReader(new FileReader(file))) {
while (readerFile.ready()) {
String line = readerFile.readLine();
for (Map.Entry entry : map.entrySet()) {
Pattern p = Pattern.compile("\\b" + entry.getKey() + "\\b");
Matcher m = p.matcher(line);
line = m.replaceAll((String) entry.getValue());
System.out.println(line);
}
}
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}