Тестил у себя на компьютере, все ок, файл корректно записывается, но программа не проходит тут проверку. В чем может быть ошибка?
package com.javarush.task.task18.task1827;
/*
Прайсы
*/
import java.io.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
public class Solution {
public static void main(String[] args) throws Exception {
// args = new String[4];
// args[0] = "-c";
// args[1] = "Rfgsdfg rgwe fe";
// args[2] = "666.66";
// args[3] = "17";
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
File file = new File(reader.readLine());
// File file = new File("E:\\file.txt");
FileInputStream fileInputStream = new FileInputStream(file);
reader = new BufferedReader(new InputStreamReader(fileInputStream));
ArrayList<Integer> maxID = new ArrayList<>();
while(reader.ready()){
String str = reader.readLine().substring(0,8);
char[] c = str.toCharArray();
str = "";
for(int i = 0; i < c.length; i++){
if(c[i] == ' ') continue;
str += c[i];
}
maxID.add(Integer.parseInt(str));
}
reader.close();
fileInputStream.close();
Collections.sort(maxID);
Collections.reverse(maxID);
int id = maxID.get(0)+1;
FileOutputStream fileOutputStream = new FileOutputStream(file, true);
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(fileOutputStream));
if(args[0].equals("-c")) {
String fileID = String.valueOf(id);
String name = args[1];
String price = args[2];
String quantity = args[3];
if(fileID.length() != 8){
int count = 8 - fileID.length();
for(int i = 0; i < count; i++){
fileID += " ";
}
}
if(name.length() != 30){
int count = 30 - name.length();
for(int i = 0; i < count; i++){
name += " ";
}
}
if(price.length() != 8){
int count = 8 - price.length();
for(int i = 0; i < count; i++){
price += " ";
}
}
if(quantity.length() != 4){
int count = 4 - quantity.length();
for(int i = 0; i < count; i++){
quantity += " ";
}
}
String result = fileID+name+price+quantity;
writer.write("\n"+result);
writer.close();
fileOutputStream.close();
}
}
}