TxtExportAlgorithm { public static void exportSpectra(@Nonnull File exportFile, @Nonnull Collection<MsSpectrum> spectra) throws IOException { exportSpectra(exportFile, spectra, " "); }  static void exportSpectrum(@Nonnull File exportFile, @Nonnull MsSpectrum spectrum); static void exportSpectra(@Nonnull File exportFile,
      @Nonnull Collection<MsSpectrum> spectra); static void exportSpectra(@Nonnull File exportFile,
      @Nonnull Collection<MsSpectrum> spectra, @Nonnull String delimiter); static void spectrumToWriter(@Nonnull MsSpectrum spectrum, @Nonnull Writer writer); static void spectrumToWriter(@Nonnull MsSpectrum spectrum, @Nonnull Writer writer,
      @Nonnull String delimiter); static @Nonnull String spectrumToString(@Nonnull MsSpectrum spectrum); static @Nonnull String spectrumToString(@Nonnull MsSpectrum spectrum,
      @Nonnull String delimiter);  }
@Test public void testExportSpectra() throws IOException { File file = folder.newFile(); Collection<MsSpectrum> spectra = new ArrayList<>(); spectra.add(mockSpectrum(mzValues1, intensityValues1)); spectra.add(mockSpectrum(mzValues2, intensityValues2)); TxtExportAlgorithm.exportSpectra(file, spectra); List<String> lines = Files.readAllLines(file.toPath(), Charset.defaultCharset()); assertThat(lines.toArray(new String[lines.size()]), arrayContaining(expectedTwoSpectra)); Collection<SimpleMsSpectrum> importedSpectra = TxtImportAlgorithm.parseMsSpectra(new FileReader(file)); assertThat(importedSpectra.size(), equalTo(2)); Iterator<SimpleMsSpectrum> iterator = importedSpectra.iterator(); MsSpectrum spectrum = iterator.next(); assertThat(spectrum.getMzValues()[0], equalTo(mzValues1[0])); assertThat(spectrum.getMzValues()[1], equalTo(mzValues1[1])); assertThat(spectrum.getIntensityValues()[0], equalTo(intensityValues1[0])); assertThat(spectrum.getIntensityValues()[1], equalTo(intensityValues1[1])); spectrum = iterator.next(); assertThat(spectrum.getMzValues()[0], equalTo(mzValues2[0])); assertThat(spectrum.getMzValues()[1], equalTo(mzValues2[1])); assertThat(spectrum.getIntensityValues()[0], equalTo(intensityValues2[0])); assertThat(spectrum.getIntensityValues()[1], equalTo(intensityValues2[1])); }