4,5,6 пункты не проходят.
Подскажите в чем дело.
3й день бьюсь над решением.
Что не так (может глас замылился :)...
package com.javarush.task.task18.task1827;
import java.io.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
/*
Прайсы
*/
public class Solution {
public static void main(String[] args) throws Exception {
if(args.length>0) {
if ((args[0].equals("-c") == true) && (args.length >= 4)) {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
File nameFile = new File(reader.readLine());
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(nameFile, true), "CP1251"));
String prise, count;
if(args[args.length - 2].length()>9){
prise = args[args.length - 2].substring(0, 8);
} else {
prise = args[args.length - 2];
}
if(args[args.length - 1].length()>5){
count = args[args.length - 1].substring(0, 4);
} else {
count = args[args.length - 1];
}
//String ID = id(nameFile).toString();
String str = String.format("%n%-8d%-30s%-8s%-4s",
id(nameFile), nameProduct(args),
prise,
count);
//System.out.println(str);
writer.write(str);
writer.close();
reader.close();
}
}
}
public static String nameProduct (String[] args){
String result = "";
for (int i = 1; i <= args.length -3 ; i++) {
result = result+" "+args[i];
}
if(result.length()<=30){
return result.substring(1,result.length());
}else
return result.substring(1,31);
}
public static Integer id(File nameFile) throws IOException {
Integer idProduct = 0, idTmp=0;
BufferedReader bufRead = new BufferedReader( new FileReader(nameFile));
String str;
while (bufRead.ready()){
str = bufRead.readLine();
if(!str.equals("")) {
//System.out.println(str.substring(0,8).replace(" ",""));
idTmp = Integer.parseInt(str.substring(0, 8).replace(" ", ""));
if (idProduct <= idTmp) {
idProduct = idTmp;
}
}
}
bufRead.close();
return idProduct+1;
}
}