A good answer might be:

DataInputStream and DataOutputStream

Copy Loop

The core of the program looks like this:

DataInputStream  instr;
DataOutputStream outstr;
. . . .
int data;
while ( true )
  data = instr.readUnsignedByte() ;
  outstr.writeByte( data ) ;

Repeatedly, one byte at at time is read and written, using the low-order byte of the integer variable data as an intermediate location.