public byte[] decodeData(byte[] data,int numErrorCorrectionBytes) throws ReedSolomonException, DataTooLargeException {
  if (data == null || data.length == 0) {
    return null;
  }
  if (data.length > 256) {
    throw new DataTooLargeException("Data exceeds 256 bytes! Too large");
  }
  int[] dataInts=new int[data.length];
  for (int i=0; i < data.length; i++) {
    dataInts[i]=data[i] & 0xFF;
  }
  int totalBytes=data.length - numErrorCorrectionBytes;
  decoder.decode(dataInts,numErrorCorrectionBytes);
  ByteArrayOutputStream bos=new ByteArrayOutputStream();
  for (int i=0; i < totalBytes && i < dataInts.length; i++) {
    bos.write(dataInts[i]);
  }
  return bos.toByteArray();
}

public byte [ ] decodeData ( byte [ ] data , int numErrorCorrectionBytes ) throws ReedSolomonException , DataTooLargeException { if ( data == null || data . length == 0 ) { return null ; } if ( data . length > 256 ) { throw new DataTooLargeException ( "Data exceeds 256 bytes! Too large" ) ; } int [ ] dataInts = new int [ data . length ] ; for ( int i = 0 ; i < data . length ; i ++ ) { dataInts [ i ] = data [ i ] & 0xFF ; } int totalBytes = data . length - numErrorCorrectionBytes ; decoder . decode ( dataInts , numErrorCorrectionBytes ) ; ByteArrayOutputStream bos = new ByteArrayOutputStream ( ) ; for ( int i = 0 ; i < totalBytes && i < dataInts . length ; i ++ ) { bos . write ( dataInts [ i ] ) ; } return bos . toByteArray ( ) ; }
repairs and decodes the supplied byte array , removing the error correction codes and returning the original data
