Все работает-проверял. откройте глаза, что я пропустил?
package com.javarush.task.task18.task1828;
/*
Прайсы 2
C:\Users\ДмАлИвАн\Desktop\abn.txt
*/
import java.io.*;
import java.util.ArrayList;
public class Solution {
public static void main(String[] args) throws IOException {
//args =new String[]{"-u","19847","lowarakhkhkjhkkkjhkjkkkjkjhkkk","blaster","54.2"};
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
String s = reader.readLine();
reader.close();
int id=0;
if(args[0].equals("-d")) {
ArrayList<String> list = new ArrayList<>();
BufferedReader reader1 = new BufferedReader(new FileReader(new File(s)));
while (true) {
String str = reader1.readLine();
if (str == null) {
break;
}
String strSub = str.substring(0, 8);
strSub = strSub.trim();
id = Integer.parseInt(strSub);
if(id!=Integer.parseInt(args[1])){
list.add(str);
}
}
reader1.close();
FileOutputStream fileOutputStream=new FileOutputStream(s);
String enter="\r\n";
for(int i=0;i<list.size();i++){
fileOutputStream.write(list.get(i).getBytes());
fileOutputStream.write(enter.getBytes());
}
fileOutputStream.close();
}
if(args[0].equals("-u")) {
ArrayList<String> list2 = new ArrayList<>();
//BufferedReader reader2 = new BufferedReader(new FileReader(new File(s)));
StringBuilder sb = new StringBuilder();
BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(s)));
while (true) {
String str = br.readLine();
if (str == null) { break;}
String strSub = str.substring(0, 8);
strSub =strSub.trim();
id = Integer.parseInt(strSub);
if(id!=Integer.parseInt(args[1])){
list2.add(str);
}else
if (id==Integer.parseInt(args[1])) {
String z =args[1];
if(args[1].length()<8){
int n =8-args[1].length();
for(int j=0;j<n;j++){
z+=" ";
}
}
if(args[1].length()>8){
z=strSub;
}
String r=args[2];
if(args[2].length()<30){
int n =30-args[2].length();
for(int j=0;j<n;j++){
r+=" ";
}
}
if(args[2].length()>30){
z=args[2].substring(0,30);
}
String t=args[3];
if(args[3].length()<8){
int n =8-args[3].length();
for(int j=0;j<n;j++){
t+=" ";
}
}
if(args[3].length()>8){
z=args[3].substring(0,8);
}
String p=args[4];
if(args[3].length()<4){
int n =4-args[3].length();
for(int j=0;j<n;j++){
p+=" ";
}
}
if(args[4].length()>4){
z=args[4].substring(0,4);
}
strSub = z+r+t+p;
list2.add(strSub);
}
}
br.close();
FileOutputStream fileOutputStream2=new FileOutputStream(s);
String enter="\r\n";
for(int i=0;i<list2.size();i++){
fileOutputStream2.write(list2.get(i).getBytes());
fileOutputStream2.write(enter.getBytes());
}
/*for(int i=0;i<list2.size();i++){
System.out.println(list2.get(i));
}*/
fileOutputStream2.close();
}
}
}