private static void channelCopy(ReadableByteChannel src,WritableByteChannel dest) throws IOException{
ByteBuffer buffer=ByteBuffer.allocate(10*1024);
while(src.read(buffer)!=-1){
buffer.flip();
while(buffer.hasRemaining()){
dest.write(buffer);
}
buffer.clear();
}
}
/**
* @param args
* @throws IOException
*/
public static void main(String[] args) throws IOException {
// TODO Auto-generated method stub
ReadableByteChannel source=Channels.newChannel(System.in);
WritableByteChannel dest=Channels.newChannel(System.out);
ChannelCopy.channelCopy(source, dest);
source.close();
dest.close();
}