PrintWriter fileOut = null; try { // // Set up the output file fileOut = new PrintWriter(new BufferedWriter(new FileWriter(args[1]))); } catch(Exception e1) { System.err.println("Output file "+args[1]+" is not accessible"); System.exit(1); } // // Now we are ready to output the data values to output file. // But first, we need to output the header line // "; Sample Rate sampleRate" // fileOut.println("; Sample Rate " + sampleRate); // Since the first column consists of numbers which start // at 0 and increase by 1/sampleRate every time slice, we'll // just use numSteps to recalculate these numbers. int numSteps = 0; // Finally, we print the values in reverse order (by popping // them off the stack). The first column consists of numbers // which start at 0 and increase by 1/sampleRate per row, so // we'll use numSteps/sampleRate to recalculate the appropriate // values. Uniform spacing will be accomplished by printing a tab. while (!s.isEmpty()) { fileOut.println(numSteps / sampleRate + "\t" + s.pop()); numSteps++; } // // Close the output file // fileOut.close();