}
else
{
// it's user stream (not a file)
ReadableByteChannel inch = inFile ? ((FileInputStream)in).getChannel() : Channels.newChannel(in);
WritableByteChannel outch = outFile ? ((FileOutputStream)out).getChannel() : Channels.newChannel(out);
// TODO buffers show same perfomance as bytes copy via Input/Output streams
// NIO buffers article http://www.odi.ch/weblog/posting.php?posting=371
long size = 0;
int r = 0;
ByteBuffer buff = ByteBuffer.allocate(IOBUFFER_SIZE);
buff.clear();
while ((r = inch.read(buff)) >= 0)
{
buff.flip();
// copy all
do
{
outch.write(buff);
}
while (buff.hasRemaining());
buff.clear();
size += r;