/** * Example of redirecting your output to a file instead of the screen. * * Hunter Lloyd * April 30th */ import java.io.*; public class OutputExample { public static void main(String [] args) { try{ String fileCrack = args[0]; PrintStream fileOut = new PrintStream(new FileOutputStream(fileCrack, false), true); System.setOut(fileOut); System.setErr(fileOut); } catch(ArrayIndexOutOfBoundsException e) { System.out.println("You must give a file output name"); System.exit(0); } catch(Exception e) { e.printStackTrace(); } System.out.println("This will not print to the screen, it prints to a file"); System.err.println("Same with this System.err line"); } }