-6

I'm new in java. My assignment requires using the File I/O Concept The Problem Is when I run the code for the second time, it makes the file new and the clear, I want to write the new data with the old data each other. any idea ?

and sorry for my poor english.

hmjd
  • 120,187
  • 20
  • 207
  • 252
  • 3
    Welcome to Stack Overflow. Please read the [Frequently Asked Questions](http://stackoverflow.com/faq) and [How to Ask](http://stackoverflow.com/questions/how-to-ask). Please post the relevant part of your code so we know how you're opening the file. – James Scholes May 11 '13 at 21:58
  • [Possible duplicate](http://stackoverflow.com/questions/1625234/how-to-append-text-to-an-existing-file-in-java) – user123 May 11 '13 at 21:59
  • 1
    Never hurts to go to the [source](http://www.oracle.com/technetwork/java/javase/documentation/index.html). – ChiefTwoPencils May 11 '13 at 22:00

1 Answers1

2

Both FileWriter and FileOutputStream have a constructor taking a boolean append as argument. Use this constructor with append set to true.

Reading the javadoc helps finding the solution for simple problems like that. Java also has a tutorial for almost everything. Google for someSubject Java tutorial, and you'll find them.

JB Nizet
  • 678,734
  • 91
  • 1,224
  • 1,255