Mình đang thử viết ghi file theo ObjectOutputStream vấn đề là khi mở file data.txt ra thì dử liệu ghi thành 1 hàng ngang bao gồm cả object nhìn thật rối .Xin hỏi có cách nào ghi từng object xuống dòng .
Giả sử ta có code như sau
public class ObjectOutputStreamExample {
public static void main(String[] args) throws IOException {
ObjectOutputStream oos = null ;
try {
oos = new ObjectOutputStream( new FileOutputStream( "D:\\testout.txt" ));
// create student
Student student = new Student( 1 , "Tran Hao Phong" , "Ha Noi" , 17 );
// write student
oos.writeObject(student);
System.out.println( "Success..." );
} catch (IOException ex) {
ex.printStackTrace();
} finally {
oos.close();
}
}
}

83% thành viên diễn đàn không hỏi bài tập, còn bạn thì sao?