Помогите, 2 часа сижу с4ым пунктом.
package com.javarush.task.task18.task1827;
import java.io.*;
import java.util.ArrayList;
import java.util.List;
/*
Прайсы
-c productName price quantity
*/
// args[id-1,2,3,4,5,6,7,8 pN-9-38, price - 39-46, q - 47-50)
// -c productName price quantity
public class Solution {
public static void main(String[] args) throws Exception {
if(args.length==0){
return;
}
else if(args[0].equals("-c")){
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
String file = reader.readLine();
reader.close();
try (BufferedReader rd = new BufferedReader(new FileReader(file));
BufferedWriter wr = new BufferedWriter(new FileWriter(file,true))) {
wr.newLine();
int maxId=0;
while(rd.ready()) {
int id = Integer.parseInt(rd.readLine().substring(0,8).trim());
if(id>maxId){
maxId=id;
}
}
wr.write(String.format(System.lineSeparator()+"%-8d%-30s%-8.2f%-4d",maxId+1, args[1], Float.parseFloat(args[2]), Integer.parseInt(args[3])));
}
catch (Exception e) {
}
}
}
}
Почему в файле должна появиться пустая строка?А, вижу, лишняя строка в коде.