• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Join 2 files.

 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Wow, I thought that was only when appending to a text type file. Not actually making binary files into 1.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic