/* * TextFileMaker.java * * This program demonstrates creation of a sequential text file.  The * user is prompted via a file chooser to specify the name of a file to be * created, and then is prompted via a dialog box to specify a boolean, * char, byte, short, int, long, float, double, and String to be written * to the file.  Each value is written to the file as a single line.  * * The resultant file can be read back using TextFileAccessor.java * * Copyright (c) 2000 - Russell C. Bjork * */import java.io.*;import javax.swing.*;public class TextFileMaker{    public static void main(String [] args) throws IOException    {        // Create the file        		File filename;		JFileChooser chooser = new JFileChooser(System.getProperty("user.dir"));		if (chooser.showSaveDialog(null) == JFileChooser.APPROVE_OPTION)		{			filename = chooser.getSelectedFile();		}		else			return;			        PrintWriter output = new PrintWriter(new FileWriter(filename));                // Get the values to write from the user and convert to appropriate        // types        		String [] inputLabels = { "Boolean", "Char", "Byte", "Short", 								  "Int", "Long", "Float", "Double", "String" };				String [] valuesToWrite = MultiInputPane.showMultiInputDialog(			null, inputLabels, "Values to write");                        boolean booleanValue = (new Boolean(valuesToWrite[0])).booleanValue();        char charValue = valuesToWrite[1].charAt(0);        byte byteValue = (new Byte(valuesToWrite[2])).byteValue();        short shortValue = (new Short(valuesToWrite[3])).shortValue();        int intValue = (new Integer(valuesToWrite[4])).intValue();        long longValue = (new Long(valuesToWrite[5])).longValue();        float floatValue = (new Float(valuesToWrite[6])).floatValue();        double doubleValue = (new Double(valuesToWrite[7])).doubleValue();        String stringValue = valuesToWrite[8];                // Write the values to the file                output.println(booleanValue);        output.println(charValue);        output.println(byteValue);        output.println(shortValue);        output.println(intValue);        output.println(longValue);        output.println(floatValue);        output.println(doubleValue);        output.println(stringValue);                // Close the file and we're done                output.close();        System.exit(0);    }}        