public byte[] encodeData(byte[] data,int numErrorCorrectionBytes) throws DataTooLargeException {
  if (data == null || data.length == 0) {
    return null;
  }
  if ((data.length + numErrorCorrectionBytes) > 256) {
    throw new DataTooLargeException("Data Length + Number or error correction bytes cannot exceed 256 bytes");
  }
  int totalBytes=numErrorCorrectionBytes + data.length;
  int[] dataInts=new int[totalBytes];
  for (int i=0; i < data.length; i++) {
    dataInts[i]=data[i] & 0xFF;
  }
  encoder.encode(dataInts,numErrorCorrectionBytes);
  ByteArrayOutputStream bos=new ByteArrayOutputStream();
  for (  int i : dataInts) {
    bos.write(i);
  }
  return bos.toByteArray();
}

public byte [ ] encodeData ( byte [ ] data , int numErrorCorrectionBytes ) throws DataTooLargeException { if ( data == null || data . length == 0 ) { return null ; } if ( ( data . length + numErrorCorrectionBytes ) > 256 ) { throw new DataTooLargeException ( "Data Length + Number or error correction bytes cannot exceed 256 bytes" ) ; } int totalBytes = numErrorCorrectionBytes + data . length ; int [ ] dataInts = new int [ totalBytes ] ; for ( int i = 0 ; i < data . length ; i ++ ) { dataInts [ i ] = data [ i ] & 0xFF ; } encoder . encode ( dataInts , numErrorCorrectionBytes ) ; ByteArrayOutputStream bos = new ByteArrayOutputStream ( ) ; for ( int i : dataInts ) { bos . write ( i ) ; } return bos . toByteArray ( ) ; }
encodes the supplied byte array , generating and appending the supplied number of error correction bytes to be used .
