Не проходит по 4-му пункту
package com.javarush.task.task19.task1923;
import java.io.*;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
/*
Слова с цифрами
*/
public class Solution {
public static void main(String[] args) {
try (FileReader source = new FileReader(args[0]); FileWriter destination = new FileWriter(args[1])) {
List<String> words = new ArrayList<>();
while (source.ready()) {
char c = (char) source.read();
if (!Character.isSpaceChar(c)) {
String word = String.valueOf(c);
while (source.ready() && !Character.isSpaceChar(c = (char)source.read()))
word += c;
words.add(word);
}
}
words.clear();
for (String word : words) {
if (word.contains("[0-9]"))
words.add(word);
}
destination.write(words.stream().collect(Collectors.joining(" ")));
} catch (IOException e) {
e.printStackTrace();
}
}
}