import
java.io.*;
import
java.util.*;
class
MyObjectOutputStream
extends
ObjectOutputStream {
MyObjectOutputStream()
throws
IOException
{
super
();
}
MyObjectOutputStream(OutputStream o)
throws
IOException
{
super
(o);
}
public
void
writeStreamHeader()
throws
IOException
{
return
;
}
}
public
class
CustomerCollection {
private
static
File f =
new
File(
"BankAccountt.txt"
);
public
static
boolean
readFile()
{
boolean
status =
false
;
try
{
f.createNewFile();
}
catch
(Exception e) {
}
if
(f.length() !=
0
) {
try
{
FileInputStream fis =
null
;
fis =
new
FileInputStream(
"BankAccountt.txt"
);
ObjectInputStream ois
=
new
ObjectInputStream(fis);
Customer c =
null
;
while
(fis.available() !=
0
) {
c = (Customer)ois.readObject();
long
accNo = c.getAccountNumber();
System.out.println(c.getCustomerName()
+
" & "
);
System.out.println(
c.getAccountNumber());
}
ois.close();
fis.close();
status =
true
;
}
catch
(Exception e) {
System.out.println(
"Error Occurred"
+ e);
e.printStackTrace();
}
}
return
status;
}
public
static
boolean
AddNewCustomer(Customer c)
{
boolean
status =
false
;
if
(c !=
null
) {
try
{
FileOutputStream fos =
null
;
fos =
new
FileOutputStream(
"BankAccountt.txt"
,
true
);
if
(f.length() ==
0
) {
ObjectOutputStream oos
=
new
ObjectOutputStream(fos);
oos.writeObject(c);
oos.close();
}
else
{
MyObjectOutputStream oos =
null
;
oos =
new
MyObjectOutputStream(fos);
oos.writeObject(c);
oos.close();
}
fos.close();
}
catch
(Exception e) {
System.out.println(
"Error Occurred"
+ e);
}
status =
true
;
}
return
status;
}
}