This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Java in General and the fly likes how can  I append two files Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

JavaRanch » Java Forums » Java » Java in General
Bookmark "how can  I append two files" Watch "how can  I append two files" New topic

how can I append two files

Dhan Priyan

Joined: May 10, 2009
Posts: 12
any one tell me how can i append two files in java.

but these are the steps to be done:

note: directory1 & directory2 contains same files mostly

1- read the file1 from the directory1 // it is fine for me
2- read the file2 from the directory2 // it is fine for me

3- later i need to append file2 contents to the end of the file 1. // in this part i am lost with code.

Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 32481

Do you know how to write to a file? It's basically the same code except you pass a different boolean value for append when you create the writer.

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
Dhan Priyan

Joined: May 10, 2009
Posts: 12
thanks for the kind reply.
i was playing with this code, but i could not understand where to give the file names.
it might help me to link the directory part with this code later.

I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link:
subject: how can I append two files
It's not a secret anymore!