jQuery in Action, 2nd edition*
The moose likes I/O and Streams and the fly likes Join 2 files. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "Join 2 files." Watch "Join 2 files." New topic
Author

Join 2 files.

Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

Does anyone know how to join 2 files into 1 bigger file. Say an AVI file? I know how to copy one file from one location to another, but I want to copy two files into one file.
Thanks.


GenRocket - Experts at Building Test Data
Jim Yingst
Wanderer
Sheriff

Joined: Jan 30, 2000
Posts: 18671
FileOutputStream and FileWriter both have constructors which allow you to specify a boolean argument. If set to true you open in "append" mode, so newly-written bytes are added to the end of an existing file. (Otherwise the default is to overwrite any existing file.) So you can copy the first file to its new location (or leave it in place if you prefer.) Then read from the second file, and use a Writer or OutputStream in append mode to add what you've read to the first file.


"I'm not back." - Bill Harding, Twister
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

Wow, I thought that was only when appending to a text type file. Not actually making binary files into 1.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Join 2 files.