java - How to save console output to a txt file and then display it on the screen right after? -


i kind of confused how write console output txt file , display right after. appreciated. code used far:

public static void savedata(){     try {         printstream myconsole = new printstream(new file("result.txt"));         system.setout(myconsole);         myconsole.print(generatereport());     }     catch(filenotfoundexception e){         system.out.println(e);     }  } public static void displaydata(){     file file = new file("result.txt");     try {         scanner input = new scanner(file);         while (input.hasnext()){             string num = input.nextline();             system.out.println(num);         }     }     catch(filenotfoundexception e){         system.out.println(e);     }  } 


Comments

Popular posts from this blog

matlab - error with cyclic autocorrelation function -

django - (fields.E300) Field defines a relation with model 'AbstractEmailUser' which is either not installed, or is abstract -

c# - What is a good .Net RefEdit control to use with ExcelDna? -