Hello Sachith,
This is Hariprasad Govardhanam, Regarding your problem about storing of data in a
file.
Sorry, I didn't see your mail, I know that you asked this for your assignment, and
the last day is over. But it is always better to remember what you have to. I don't
know why people think deep when the answer lies on the top.
The problem is very simple, just store all the data into a Vector then simply
store that vector into a file using a ObjectOutputStream. And this works, it is very
very simple, no problems at all. If there is a problem occuring, then that is because
of your code. I have written a program using this.
Code to write into file:
try {
FileOutputStream foutcd=new FileOutputStream("CD.jxt");
ObjectOutputStream objoutcd=new ObjectOutputStream(foutcd);
objoutcd.writeObject(Cds);
objoutcd.close();
}catch(FileNotFoundException e){
JOptionPane.showMessageDialog(null,"Unable to save");
}catch(IOException e){
JOptionPane.showMessageDialog(null,"IOException Caught");
e.printStackTrace();
};
And the code to read it is:
try {
FileInputStream fpcd=new FileInputStream("myfile");
ObjectInputStream objcd=new ObjectInputStream(fpcd);
Cds=(Vector)objcd.readObject();
objcd.close();
}catch(FileNotFoundException e) {
JOptionPane.showMessageDialog(null,"File Not Found");
}catch(IOException e){
JOptionPane.showMessageDialog(null,"IOException caught");
e.printStackTrace();
}catch(Exception e){ };
Hope this is useful for you
---------------------------------
Do you Yahoo!?
Yahoo! Mail - Helps protect you from nasty viruses.
[Non-text portions of this message have been removed]
------------------------ Yahoo! Groups Sponsor --------------------~-->
Make a clean sweep of pop-up ads. Yahoo! Companion Toolbar.
Now with Pop-Up Blocker. Get it for free!
http://us.click.yahoo.com/L5YrjA/eSIIAA/yQLSAA/5cFolB/TM
--------------------------------------------------------------------~->
If you have any comments or questions, submit it on the message board.
NO spam/ads/job posting or you will be BANNED from this group. Exception can be made
it happen by notify me ahead of time.
all new members' message will be verified by me (spam..) before it get posted.
Yahoo! Groups Links
<*> To reply to this message, go to:
http://groups.yahoo.com/group/java_official/post?act=reply&messageNum=17301
Please do not reply to this message via email. More information here:
http://help.yahoo.com/help/us/groups/messages/messages-23.html
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/java_official/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/