public void writeToFile(String fileName) throws IOException {
  PrintWriter outfile=new PrintWriter(new FileOutputStream(fileName));
  outfile.println("// Output from Histogram class");
  outfile.println("// metaData: ");
  outfile.println("bins " + m_nbins);
  outfile.println("min " + m_min);
  outfile.println("max " + m_max);
  outfile.println("totalEntries " + m_entries);
  outfile.println("underflow " + m_underflow);
  outfile.println("overflow " + m_overflow);
  outfile.println("// binData:");
  for (int i=0; i < m_nbins; i++) {
    outfile.println(i + " " + m_binCenters[i]+ " "+ m_hist[i]);
  }
  outfile.println("// end.");
  outfile.close();
}

public void writeToFile ( String fileName ) throws IOException { PrintWriter outfile = new PrintWriter ( new FileOutputStream ( fileName ) ) ; outfile . println ( "// Output from Histogram class" ) ; outfile . println ( "// metaData: " ) ; outfile . println ( "bins " + m_nbins ) ; outfile . println ( "min " + m_min ) ; outfile . println ( "max " + m_max ) ; outfile . println ( "totalEntries " + m_entries ) ; outfile . println ( "underflow " + m_underflow ) ; outfile . println ( "overflow " + m_overflow ) ; outfile . println ( "// binData:" ) ; for ( int i = 0 ; i < m_nbins ; i ++ ) { outfile . println ( i + " " + m_binCenters [ i ] + " " + m_hist [ i ] ) ; } outfile . println ( "// end." ) ; outfile . close ( ) ; }
save the histogram data to a file . the file format is very simple , human - readable text so it can be imported into excel or cut & pasted into other applications .
