Java File Output Check -


i have written long amount of code , trying write output file code-

file outfile = new file ("output.txt"); printwriter outfile = new printwriter(outfile); outfile.printf("%-20s%5s%5s%5s%5s", f,median,avg,min,max); outfile.println(""); outfile.printf("%-20s%5s%5s%5s%5s", f,median,avg,min,max); outfile.println(""); outfile.printf("%-27s%5d%5d%5d%5d", firstplayer,p1median,p1avg,pscore.get(0),pscore.get(pscore.size()-1)); outfile.println(""); outfile.printf("%-27s%5d%5d%5d%5d", secondplayer,p2median,p2avg,player2.get(0),player2.get(player2.size()-1)); outfile.println(""); outfile.printf("%-27s%5d%5d%5d%5d",fourthplayer,p4median,p4avg,player4.get(0),player4.get(player4.size()-1)); outfile.close(); 

now had no errors or exceptions thrown believe have succeed in writing output file, have no idea located , how can check content of it. apologize if bad question struggling find answer elsewhere, locating output file or correcting mistakes appreciated greatly.

this print out full file path if you're still unsure it's located:

system.out.println(outfile.getabsolutepath());

if want print out contents of file can examine in program:

//ensure content in file updated outfile.flush();  bufferedreader br = null; try {     br = new bufferedreader(new filereader(outfile));     string line;     while ((line = br.readline()) != null) {          system.out.println(line);     } } catch (ioexception e) {     e.printstacktrace(); } {     try {         br.close();     }     catch (ioexception e) {         e.printstacktrace();     } } 

make sure close file well.


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -