accessFile.seek(indexElement.getStart()); int size = indexElement.getSize();
file.seek(indexElement.getStart()); byte[] buffer = new byte[indexElement.getSize()]; file.read(buffer);
inputFile.seek(indexElement.getStart()); byte[] bytes = new byte[indexElement.getSize()]; inputFile.read(bytes);
accFile.seek(indexElement.getStart()); accFile.read(byteBuffer); String ms2Buffer = new String(byteBuffer);
public static Spectrum getIndexedSpectrum(File sourcefile, uk.ac.ebi.pride.tools.jmzreader.model.IndexElement indexElement) throws JMzReaderException { RandomAccessFile access = null; try { // read the XML from the file access = new RandomAccessFile(sourcefile, "r"); // create the byte buffer byte[] bytes = new byte[indexElement.getSize()]; // move to the position in the file access.seek(indexElement.getStart()); // read the snipplet access.read(bytes); // create and return the string String snipplet = new String(bytes); MzXMLUnmarshaller localUnmarshaller = MzXMLUnmarshallerFactory.getInstance().initializeUnmarshaller(); Scan scan = localUnmarshaller.unmarshal(snipplet, MzXmlElement.SCAN_LEVEL1); return new MzXMLSpectrum(scan); } catch (Exception e) { throw new JMzReaderException("Failed to read from mzXML file.", e); } finally { if (access != null) { try { access.close(); } catch (IOException e) { // ignore } } } }
byte[] buffer = new byte[indexElement.getSize()]; accessFile.seek(indexElement.getStart()); accessFile.read(buffer);