DAO 에서 만든 디스플레이() 이거 콘솔창에 뜨는 거 그대로
WRITE() 에 쓰게끔 하고 싶은데
콘솔 창에 뜨는 거랑
쓰인 거와 다른거임..?
왜 똑같은 짓을 두 번 하는겨
public class Fruitmain {
public static void main(String[] args) {
try {
String InputPath = "fruit.txt";
FileReader fr = new FileReader(InputPath);
BufferedReader br = new BufferedReader(fr);
String line = null;
FruitDTO dto = null;
ArrayList<FruitDTO> list = new ArrayList<>();
while ((line=br.readLine()) != null ) {
String[] sp =line.split(" ");
dto = new FruitDTO();
dto.setName(sp[0]);
dto.setCost(Integer.parseInt(sp[1]));
dto.setSu(Integer.parseInt(sp[2]));
list.add(dto);
}//while
FruitDAO dao = new FruitDAO(list);
dao.getPrice();
dao.display();
dao.priceDescSort();
dao.display();
String OutputPath = "result.txt";
FileWriter fw = new FileWriter(OutputPath);
BufferedWriter bw = new BufferedWriter(fw);
int index = 0;
DecimalFormat df = new DecimalFormat("₩#,##0");
DecimalFormat cf = new DecimalFormat("#,#00개");
for (FruitDTO i : list) {
if (index < list.size()-1) {
index++;
bw.write(i.getName()+" "+df.format(i.getCost())+" "+cf.format(i.getSu())+" "+df.format(i.getPrice())+" ");
} else {
index++;
bw.write(i.getName()+" "+df.format(i.getCost())+" "+cf.format(i.getSu())+" "+df.format(i.getPrice())+" ");
bw.write("=========================");
bw.flush();
syso("파일이 생성됐습니다.");
}//if
}// for each
bw.close();
fw.close();
br.close();
fr.close();
} catch (Exception e) {
e.printStackTrace();
}//try~ catch
}//main();
}//class
DAO display 에 있는 syso 들이 제일 밑에 write 값과 같은데 근데 write( dao.display() ) 하면 int나 string 에러떠서 안됨...