The a.txt file is as follows:
ABC
The d.txt file looks like this:
DEF
I am trying to take βDEFβ and add it to βABCβ, so a.txt looks like
ABC DEF
The methods I tried always overwrite the first record completely, so I always get:
DEF
Here are two methods I've tried:
FileChannel src = new FileInputStream(dFilePath).getChannel(); FileChannel dest = new FileOutputStream(aFilePath).getChannel(); src.transferTo(dest.size(), src.size(), dest);
... and I tried
FileChannel src = new FileInputStream(dFilePath).getChannel(); FileChannel dest = new FileOutputStream(aFilePath).getChannel(); dest.transferFrom(src, dest.size(), src.size());
The API is unclear about the listing and passing from the parameter description here:
http://docs.oracle.com/javase/7/docs/api/java/nio/channels/FileChannel.html#transferTo(long , long, java.nio.channels.WritableByteChannel)
Thanks for any ideas.
source share