Помогите, пожалуйста, я переделываю эту программу у же 40-50 раз и все равно валидатору не нравится. Проверяю через блокнот, все выводит как надо...
package com.javarush.task.task18.task1827;
/*
Прайсы
*/
import java.io.*;
public class Solution {
public static void main(String[] args) throws Exception {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
String fileName = reader.readLine();
reader.close();
if (args.length > 0 && args[0].equals("-c")) {
StringBuilder name = new StringBuilder();
String productName;
int id = 0;
if (args.length > 4) {
for (int i = 1; i < args.length - 2; i++) {
name.append(args[i]).append(" ");
}
}
productName = String.format("%-30.30s", name.toString());
String price = String.format("%-8.8s", args[args.length - 2]);
String quantity = String.format("%-4.4s", args[args.length - 1]);
BufferedReader fileReader = new BufferedReader(new FileReader(fileName));
while (fileReader.ready()) {
String newLine = fileReader.readLine().substring(0, 8).replace(" ", "");
id = Integer.parseInt(newLine) + 1;
}
String newId = String.format("%-8.8s", String.valueOf(id));
FileWriter fileOutputStream = new FileWriter(fileName, true);
fileOutputStream.write("\n" + newId + productName + price + quantity);
fileOutputStream.close();
fileReader.close();
}
}
}