Всё работает, проверочные параметры задаю, всё проходит. Что ему нужно?
package com.javarush.task.task18.task1827;
/*
Прайсы
*/
import java.io.*;
import java.util.ArrayList;
public class Solution {
public static void main(String[] args) throws Exception {
ArrayList<Integer> list = new ArrayList<>();
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
String file = reader.readLine();
FileReader inputStream = new FileReader(file);
FileWriter outputStream = new FileWriter(file, true);
int max = 0;
int maxid = 0;
String sid = null, sproductName = null, sprice = null, squantity = null, addstring = null;
char [] mas = new char[(int) (new File(file).length()+1)];
inputStream.read(mas);
String string = new String(mas);
double dlina = string.length()/50;
String string2 = string.substring(0, 7);
list.add(Integer.parseInt(string2.replaceAll(" ", "")));
for (int i = 1; i < dlina; i++) {
String string1 = string.substring(50 * i-1, 50 * i + 6);
list.add(Integer.parseInt(string1.replaceAll(" ", "")));
}
if (list.size() > 1){
for (int i = 0; i < list.size();i++){
for (int j = list.size() - 1; j >= i; j--){
if (list.get(i) > list.get(j)){
max = list.get(i);
list.set(i, list.get(j));
list.set(j, max);
}
}}
}
maxid = list.get(list.size()-1);
sid = String.valueOf(maxid+1);
for(int i = sid.length(); i < 8; i++){
sid = sid + " ";
}
if(args[1]!=""){
sproductName = args[1];
if(sproductName.length() > 30){
sproductName = sproductName.substring(0, 30);
}
for (int i = sproductName.length(); i < 30; i++){
sproductName = sproductName + " ";
}}
if (args[2]!=""){
sprice = args[2];
for (int i = sprice.length(); i < 8; i++){
sprice = sprice + " ";
}}
if (args[3]!="") {
squantity = args[3];
for (int i = squantity.length(); i < 4; i++) {
squantity = squantity + " ";
}}
addstring = sid + sproductName + sprice + squantity;
if (args[0].equals("-c")){
outputStream.write(addstring);}
else {
reader.close();
inputStream.close();
outputStream.close();
}
reader.close();
inputStream.close();
outputStream.close();
}
}