1 Reply Latest reply on Nov 11, 2009 5:04 PM by 807580

    Writing to file(using PrintWrier)

      Im trying to do a simple program that will write system information into a file for data basing.
      But the problem is it creates the file but does not write anything ive used other methods. But they would
      not let me write to a new line in the .dat file. Im looking for a quick and easy solution. Help is appreciated

      import java.io.*;
      import java.util.*;
      public class MLS_writer {
           public static void main(String args [] ) {
                PrintWriter out = new PrintWriter(new FileWriter("C:\\bank.dat"));
                // make file writer
                     out.println("USER DATA");
                     out.println("User name=");
                     String getinput;
                     System.out.println("Enter the account your currently logged in on");
                     Scanner getin = new Scanner(System.in);
                     getinput =     getin.next();
                     //out.println ("\n");
                     //out.println("Computer operationg sysetm=");
                     System.out.println("Enter computer operating system.");
                     String osinput;
                     osinput = getin.next();
                     out.println("operationg system=" + osinput);
                     out.println("Command line/shell=default");
                     }catch (Exception e) {
                          System.out.println("Error: " + e.getMessage());
                          System.out.println("Unable to write file Mbank.dat");