How to add data to an existing file and also read it with Java -
this simple program user inputs 2 variable values , chooses operator. program displays results , asks user if save file. format should x + y = z. declared variable should catch user input
resw = "";
i unable resw capture user input variable values can saved file. if enter
resw = "x + y = z";
then saved. second problem...when saves writes on previous save. need save each entry new line. don't know how that.
finally, view file well. far can tell need filereader , bufferedreader so. not working though , moves on next line of code.
if (answer.equals("y")||answer.equals("y")){ system.out.println(resw); bufferedwriter.write(resw); bufferedwriter.newline(); system.out.println("results saved file."); } system.out.println("do want review results y/n"); answer = ins.nextline(); if (answer.equals("y")||answer.equals("y")){ filereader filereader = new filereader(filename); bufferedreader bufferedreader = new bufferedreader(filereader); }
just use printwriter, , printwriter.println, , sure close file
if (answer.equals("y")||answer.equals("y")) { system.out.println(resw); printwriter.println(resw); printwriter.close();
Comments
Post a Comment