Нужен файл с которым программа будет некорректно работать.
package com.javarush.task.task19.task1923;
/*
Слова с цифрами
*/
import java.util.*;
import java.io.*;
public class Solution {
public static void main(String[] args) throws Exception {
BufferedReader reader = new BufferedReader(new FileReader(args[0]));
BufferedWriter writer = new BufferedWriter(new FileWriter(args[1]));
ArrayList<String> massiv = new ArrayList<String>();
String chisla = "0123456789";
// String all = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzабвгдеёжзийклмнопрстуфхцчшщъыьэюяАБВГДЕЁЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯ";
String prepin = ".,:;-...?!\"()";
String s;
while ((s = reader.readLine()) != null) {
massiv.add(s);
}
int count = 0;
for (int i = 0; i < massiv.size(); i++) {
String a = massiv.get(i);
String[] sp = a.split(" ");
for (int j = 0; j < sp.length; j++) {
String d = sp[j].trim();
String res1 = "";
String res2 = "";
String res3 = "";
String res4 = "";
for (int q = 0; q < d.length(); q++) {
if (!chisla.contains(d.substring(q, q + 1)) && !prepin.contains(d.substring(q, q + 1))) {
res1 = "a";
break;
}
}
for (int w = 0; w < d.length(); w++) {
if (chisla.contains(d.substring(w, w + 1))) {
res2 = "a";
break;
}
}
for (int c = 0; c < d.length(); c++) {
if (prepin.contains(d.substring(c, c + 1))) {
res3 = "b";
break;
}
}
int schet = 0;
for (int z = 0; z < d.length(); z++) {
if (d.substring(z, z + 1).equals(" ")) {
schet++;
}
}
if (schet == d.length()) {
res4 = "b";
}
String result = res1 + res2 + res3 + res4;
if (result.equals("aa") && count == 0) {
writer.write(d);
count++;
}
else if (result.equals("aa") && count != 0) {
writer.write(" " + d);
count++;
}
}
}
writer.close();
reader.close();
}
}