Results 1 to 1 of 1
Thread: How to redirect the output
- 10-04-2007, 09:30 PM #1
How to redirect the output
This tip will show the way to redirect the output of the System.out.println() to a file.
Java Code:import java.io.File; import java.io.FileNotFoundException; import java.io.PrintStream; public class RedirectOutputExp { public static void main(String[] args) { // Creates a file object File file = new File("C:\\MyFile.txt"); try { // Creates and PrintStream Object for the File. PrintStream printStream = new PrintStream(file); // Redirect the output to the printStream. System.setOut(printStream); System.out.println("This is redirected output"); } catch (FileNotFoundException e) { e.printStackTrace(); } } }
Similar Threads
-
How to redirect the output
By Java Tip in forum java.ioReplies: 0Last Post: 04-04-2008, 02:36 PM -
how to redirect the output buffer of pl/sql onto a jsp
By sriavr in forum JDBCReplies: 0Last Post: 03-11-2008, 12:25 PM -
Redirect to null device
By Java Tip in forum Java TipReplies: 0Last Post: 02-05-2008, 09:05 AM -
how to redirect the browser
By simon in forum Java AppletsReplies: 1Last Post: 08-02-2007, 05:24 PM -
How can I redirect in servlet?
By Heather in forum Java ServletReplies: 1Last Post: 07-14-2007, 05:52 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks