Все шикарно выводится отлично в консоль.
package com.javarush.task.task19.task1924;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/*
Замена чисел
*/
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) throws IOException {
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));
String fileName = bufferedReader.readLine();
bufferedReader.close();
List<String> stringList = new ArrayList<>();
try (BufferedReader fileReader = new BufferedReader(new FileReader(fileName))) {
while (fileReader.ready()) {
stringList.add(fileReader.readLine());
}
for (String line: stringList) {
String newLine = line.replaceAll("\\Q12\\E", map.get(12))
.replaceAll("\\Q11\\E", map.get(11))
.replaceAll("\\Q10\\E", map.get(10))
.replaceAll("\\Q9\\E", map.get(9))
.replaceAll("\\Q8\\E", map.get(8))
.replaceAll("\\Q7\\E", map.get(7))
.replaceAll("\\Q6\\E", map.get(6))
.replaceAll("\\Q5\\E", map.get(5))
.replaceAll("\\Q4\\E", map.get(4))
.replaceAll("\\Q3\\E", map.get(3))
.replaceAll("\\Q2\\E", map.get(2))
.replaceAll("\\Q1\\E", map.get(1))
.replaceAll("\\Q0\\E", map.get(0));
System.out.println(newLine);
}
}
}
}