It says there is a problem with line 47 method strip() and when I gray it out next problem is with line 55 method repeat(), please help me
package com.codegym.task.task18.task1827;
/*
Prices
*/
import java.io.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
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();
FileInputStream fis = new FileInputStream(fileName);
FileWriter fw = new FileWriter(fileName, true);
String op = args[0];
String productName = args[1];
String price = args[2];
String quantity = args[3];
if(op.equals("-c")) {
String line;
String id = formatId(calculateNewId(fis));
productName = formatProductName(productName);
price = formatPrice(price);
quantity = formatQuantity(quantity);
line = "" + id + productName + price + quantity;
fw.write(line);
}
fis.close();
}
private static String calculateNewId(FileInputStream fis) throws IOException {
String line;
int maxId = 0;
BufferedReader br = new BufferedReader(new FileReader(String.valueOf(fis)), 8);
while((line = br.readLine()) != null){
//line = line.strip();
int id = Integer.parseInt(line);
if (maxId<id){
maxId = id;
}
}
maxId += 1;
String newMaxId = Integer.toString(maxId);
StringBuilder newStr = new StringBuilder();
newStr.append(" ".repeat(8 - Math.min(newMaxId.length(), 8)));
return newStr.toString();
}
private static String formatString(String str, int limit) {
StringBuilder newStr = new StringBuilder();
for(int i = 0; i < Math.min(str.length(), limit); i++){
newStr.append(str.charAt(i));
}
newStr.append(" ".repeat(limit - Math.min(str.length(), limit)));
return newStr.toString();
}
private static String formatQuantity(String quantity) {
return formatString(quantity, 4);
}
private static String formatPrice(String price) {
return formatString(price, 8);
}
private static String formatProductName(String productName) {
return formatString(productName,30);
}
private static String formatId(String id) {
return formatString(id,8)+1;
}
}