The Artima Developer Community
Sponsored Link

Java Answers Forum
Writing to a file.

2 replies on 1 page. Most recent reply: Apr 30, 2003 3:10 PM by James Patterson

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 2 replies on 1 page
Al

Posts: 2
Nickname: bobo
Registered: Apr, 2003

Writing to a file. Posted: Apr 30, 2003 3:01 AM
Reply to this message Reply
Advertisement
How can i write results of a program to file.??


Rahul

Posts: 52
Nickname: wildhorse
Registered: Oct, 2002

Re: Writing to a file. Posted: Apr 30, 2003 4:08 AM
Reply to this message Reply
This would work in windows2000:

C:\>java filename > filename.txt
else use java.io package. Check this url: http://www.javacoffeebreak.com/java103/java103.html

James Patterson

Posts: 16
Nickname: jmep
Registered: Mar, 2003

Re: Writing to a file. Posted: Apr 30, 2003 3:10 PM
Reply to this message Reply
While using the redirect method, if you expect Exceptions (and you should) you might add something like the following code to your main:
PrintStream _holdErr = System.err;
System.setErr(System.out);


Of course if your original question was more like how do you write data to a file (vs System.out.println() calls) see:

http://java.sun.com/docs/books/tutorial/essential/io/index.html

Hope this helps,
James

Flat View: This topic has 2 replies on 1 page
Topic: Criteria to choose between JSP and Applet Previous Topic   Next Topic Topic: create a streamwriter

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use