private byte[] copyArray(byte[] buffer,int length){
  byte[] result=new byte[length];
  System.arraycopy(buffer,0,result,0,Math.min(buffer.length,length));
  return result;
}

private byte [ ] copyArray ( byte [ ] buffer , int length ) { byte [ ] result = new byte [ length ] ; System . arraycopy ( buffer , 0 , result , 0 , Math . min ( buffer . length , length ) ) ; return result ; }
implement java . util . arrays . copyof ( ) for jdk 1 . 5 .
