• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Output to text file

 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi.

I'm trying to finish an assignment and need to write up some test results. I'd like to know if it's possible to send the screen output directly to a text file so I don't have to sit and type it all in.

Can anyone tell me if this is possible and how it is done.
 
Ranch Hand
Posts: 328
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In Windows:

you can copy to the system clipboard your program's output from it's console window, and then paste it to a text file opened in a text editor, or

you can run your program like this: c:\>java yourclass >out.txt, or

you can modify your code to make the program output to the text file. Here is a piece of code as an example:



[ July 20, 2004: Message edited by: Dmitry Melnik ]
[ July 20, 2004: Message edited by: Dmitry Melnik ]
 
Ranch Hand
Posts: 153
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dmitry, 2 things:
1)I had never known that you could use c:\>java yourclass >out.txt it is very helpful and I'm glad I ran across your reply to Simon.
2)when using a printstream I thought you had to use outFile.close(); or is that just optional?

Thanks-Dan
 
Dmitry Melnik
Ranch Hand
Posts: 328
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
you had to use outFile.close();

Thanks. You are right. Fixed
 
reply
    Bookmark Topic Watch Topic
  • New Topic