/* * Main.java * * Created on February 15, 2008, 3:11 PM * * To change this template, choose Tools | Template Manager * and open the template in the editor. */package javaapplication1;import java.util.Calendar;import java.text.SimpleDateFormat;import java.io.*;/** * * @author pullin */public class Main { private static final double MAGIC = 0.8065; private static final int NUMSAMPLES = 256; private static double freq[] = linspace(0,400/MAGIC,NUMSAMPLES); private double[] data; public static final String DATE_FORMAT_NOW = "MM-dd HHmmss"; private static File flog = new File("log "+ now() + ".txt"); /** Creates a new instance of Main */ public Main() { data = new double[] {1,2,3}; output(); data = new double[] {6,7,8,9}; output(); } /** * @param args the command line arguments */ public static void main(String[] args) { // TODO code application logic here } private static double[] linspace(double start, double end, int num) { double[] space = new double[num]; double d = (end-start)/(num-1); double temp=start+d; space[0]=start; //This way should require less multiplies for(int i=1; i<num; i++) { space[i]=temp; temp += d; } return space; } public static String now() { Calendar cal = Calendar.getInstance(); SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT_NOW); return sdf.format(cal.getTime()); } private void output(){ try { BufferedWriter fout = new BufferedWriter(new FileWriter(flog)); for(double D : data){ fout.write(Double.toString(D)); fout.newLine(); //platform independant newline } fout.write("---"); fout.close(); //have to close to flush the buffer } catch (IOException ex) { ex.printStackTrace(); //Stock exception catching } }}