public void Collection()
{
Ccollection = new Customer[300];
Customer obj = null;
count = 0;
FileInputStream fis = null;
ObjectInputStream ois = null;
try {
fis = new FileInputStream("Customerlist");
ois = new ObjectInputStream(fis);
while ((obj = (Customer) ois.readObject()) != null) {
Ccollection[count] = new Customer();
Ccollection[count] = obj;
System.out.print(Ccollection[count].getAge()
+ Ccollection[count++].getHeight());
}
fis.close();
ois.close();
} catch (ClassNotFoundException cnfe) {
} catch (IOException e) {
//계속 여기로 빠짐
}
}
파일에서 읽어와서 customer객체 배열로 모아 올라고 하는데 IOException때매 try구문이 실행이 안된다
각 줄마다 주석치면서 알아본 결과 try구문 2번째줄 ois = new ObjectInputStream(fis); 이거때매 예외상황 발생하는거 같긴한데 잘 모르겠음
코드도 빙구인 내가 짠거 아니고 여기저기서 보고 한건데 도저히 머가 문젠지 모르겟어요 도와줘잉 마리텔 러블리즈나오는데 이쁘당 ㅎㅎ
이럴 땐 빨간 경고도 알려주면 쉬워요
에러는 안나고 경고도 이거랑 관련잇는건 없어요. 변수 선언한거 안썻다는거밖에
e.printstacktrace 이걸 catch 안에 넣어봐요
e.printstacktrace() 추가하니깐 java.io.StreamCorruptedException: invalid stream header: 73720018 이런 오류가 뜨네요!