Не могу разобраться, что не нравится валидатору. Особенно интересно, что он докопался к закрытию потока чтения, уже и так и сяк пробовал.
package com.javarush.task.task18.task1828;
import java.util.Formatter;
public class Good {
protected int id;
public int getId() {
return id;
}
protected float price;
protected String description;
public void setPrice(String price) {
this.price = Float.parseFloat(price.replaceAll(" ", ""));
}
public void setDescription(String description) {
this.description = description;
}
public void setCount(String count) {
this.count = Integer.parseInt(count.replaceAll(" ", ""));
}
protected int count;
public Good (String formatedString){
String str = formatedString.substring(0, 8);
id = Integer.parseInt(str.replaceAll(" ", ""));
description = formatedString.substring(8, 38);
str = formatedString.substring(38, 46);
price = Float.parseFloat(str.replaceAll(" ", "").replaceAll(",", "."));
str = formatedString.substring(46);
count = Integer.parseInt(str.replaceAll(" ", ""));
}
@Override
public String toString()
{
Formatter fmt = new Formatter();
String res = fmt.format("%-8d%-30s%-8.2f%-4d", id, description, price, count).toString();
fmt.close();
res.replaceAll(".", ",");
return res;
}
}