Hi Sachith,
If you are using FileOutputStream to store your data,
you have to use the constructor as follows
FileOutputStream("OutFile.txt", true)
But if u are using FileOutputStream("OutFile.txt") the
default behavior will OVERWRITE ur file whenever u
call FileOutputStream.write() method.
so pass "true" as second argument, means do you want
to append to the file ??? "YES"
regards,
S.Vasanth Kumar.
import java.io.*;
import java.util.Date;
public class AppendDemo
{
public static void main(String args[])
{
try
{
OutputStream out = new
FileOutputStream("AppendLog.txt", true); // true here
is v.v.imp to append the future contents
out.write(("Program executed on: " + new Date() +
"\r\n").getBytes());
out.flush();
out.close();
}
catch(Exception ex)
{
System.out.println(ex.toString());
}
}
}
--- Sachith Dassanayake <[EMAIL PROTECTED]> wrote:
>
>
> I 'm doing a simple program on file handling in
> JAVA.
> I need to store 3 data
>
> 1 First Name
> 2 Last Name
> 3 Phone Number
> in to a file. (Not a
> Database). I
> tryed to do it using
> datainputstreams etc.. But when i enter the second
> record it
> over writes the first record.
> How can i over ome this problem
>
> Also I hav to display all the records in a table
> after entering.
> It has to be worked even I close the program and
> reopen it.
>
> It would be greatful if any one can help me on my
> program.
>
> Thank you
> Sachith
> ---------------------------------------------
> Free POP3 Email from www.Gawab.com
> Sign up NOW and get your account @gawab.com!!
>
>
> [Non-text portions of this message have been
> removed]
>
>
>
>
>
________________________________________________________________________
Yahoo! India Matrimony: Find your partner online.
http://yahoo.shaadi.com/india-matrimony/
------------------------ Yahoo! Groups Sponsor --------------------~-->
$9.95 domain names from Yahoo!. Register anything.
http://us.click.yahoo.com/J8kdrA/y20IAA/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=17251
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/