Помогите, пожалуйста, понять, что же еще требуется.
Как будто все работает.
package com.javarush.task.task18.task1827;
import java.io.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/*
Прайсы
*/
public class Solution {
public static void main(String[] args) throws Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String filePath = br.readLine();
br.close();
List<Integer> idies = new ArrayList<>();
try {
BufferedReader reader = new BufferedReader(new FileReader(new File(filePath)));
String line = reader.readLine();
while (line != null) {
String substr = line.substring(0,8);
substr = substr.replaceAll("\\s","");
idies.add(Integer.parseInt(substr));
line = reader.readLine();
}
reader.close();
} catch (Exception e) {
e.printStackTrace();
}
Collections.sort(idies);
int lastNum = 0;
for (int i : idies){
lastNum = i;
}
lastNum++;
if (idies.isEmpty()){
lastNum = Integer.parseInt(args[0]);
}
if (args.length > 0) {
if (args[0].equals("-c")) {
//int id = Integer.parseInt(args[0]);
int id = lastNum;
String productName = args[1];
int price = Integer.parseInt(args[2]);
int quantity = Integer.parseInt(args[3]);
String strId = "" + lastNum;
String strProductName = args[1];
String strPrice = args[2];
String strQuantity = args[3];
while (strId.length() < 8){
strId = strId + " ";
}
while (strProductName.length() < 30){
strProductName = strProductName + " ";
}
while (strPrice.length() < 8){
strPrice = strPrice + " ";
}
while (strQuantity.length() < 4){
strQuantity = strQuantity + " ";
}
FileOutputStream fileOutputStream = new FileOutputStream(filePath, true);
String full = ""+strId+strProductName+strPrice+strQuantity;
fileOutputStream.write(full.getBytes());
fileOutputStream.close();
}
}
}
}