// make a data input stream
DataInputStream peakStream = new DataInputStream(
new ByteArrayInputStream(peakBytes));
DataPoint completeDataPoints[] = new DataPoint[peaksCount];
try {
for (int i = 0; i < completeDataPoints.length; i++) {
// Always respect this order pairOrder="m/z-int"
double massOverCharge;
double intensity;
if ("64".equals(precision)) {
massOverCharge = peakStream.readDouble();
intensity = peakStream.readDouble();
} else {
massOverCharge = (double) peakStream.readFloat();
intensity = (double) peakStream.readFloat();
}
// Copy m/z and intensity data
completeDataPoints[i] = new SimpleDataPoint(
massOverCharge, intensity);
}
} catch (IOException eof) {
setStatus(TaskStatus.ERROR);
errorMessage = "Corrupt mzXML file";
throw new SAXException("Parsing Cancelled");
}
// Auto-detect whether this scan is centroided
boolean centroided = ScanUtils.isCentroided(completeDataPoints);
// Set the centroided tag
buildingScan.setCentroided(centroided);
// Remove zero data points
DataPoint optimizedDataPoints[] = ScanUtils
.removeZeroDataPoints(completeDataPoints, centroided);
// Set the final data points to the scan
buildingScan.setDataPoints(optimizedDataPoints);