Output is good, can anyone tell me what's the problem?
package com.codegym.task.task19.task1924;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.io.*;
/*
Replacing numbers
*/
public class Solution {
public static Map<Integer, String> map = new HashMap<Integer, String>();
static {
map.put(0, "zero");
map.put(1, "one");
map.put(2, "two");
map.put(3, "three");
map.put(4, "four");
map.put(5, "five");
map.put(6, "six");
map.put(7, "seven");
map.put(8, "eight");
map.put(9, "nine");
map.put(10, "ten");
map.put(11, "eleven");
map.put(12, "twelve");
}
public static void main(String[] args) throws IOException {
BufferedReader reader= new BufferedReader(new InputStreamReader(System.in));
BufferedReader fileReader = new BufferedReader(new FileReader(reader.readLine()));
while(fileReader.ready()) {
String text = fileReader.readLine();
String[] line = text.split(" ");
ArrayList<String> list = new ArrayList<>();
StringBuilder sb = new StringBuilder("");
for (String s : line) {
list.add(s);
}
for(int i = 0; i < list.size(); i++) {
char ch = 0;
String s = list.get(i);
if(s.endsWith(".")) {
s = s.substring(0, s.indexOf("."));
ch = '.';
}
else if(s.endsWith(",")) {
s = s.substring(0, s.indexOf(","));
ch = ',';
}
//System.out.println(s);
try {
int x = Integer.parseInt(s);
if(map.containsKey(x)) list.set(i, map.get(x) + ch);
} catch(Exception e) {
}
sb.append(list.get(i) + " ");
}
System.out.println(sb.toString().trim());
}
reader.close();
fileReader.close();
}
}