This approach is fraught with peril for binary file formats.
That is an understatement!
It has similar risks to this approach employed with, say, .jpg, .wav
or .mp3 files.
For binary formats, you could use SPLICE, a C++ utility.
See
http://mindprod.com/products1.html#SPLICE
Or you could read byte[], and agglutinate with a ByteArrayStream using
bytes only, no chars. A ByteArrayStream acts something like a
StringBuilder but for bytes. It grows a backing byte[] store as
needed.
see
http://mindprod.com/applet/fileio.html
Make very sure you work with bytes with no encoding. As soon as you
turn on any sort of encoding all manner of queer things will happen,
though the code will work for text files.
COPY /B a + b c
will concatenate binary files .
--
Roedy Green Canadian Mind Products
http://mindprod.com
PM Steven Harper is fixated on the costs of implementing Kyoto, estimated as high as 1% of GDP.
However, he refuses to consider the costs of not implementing Kyoto which the
famous economist Nicholas Stern estimated at 5 to 20% of GDP