I'm trying to copy my program output to a text file and still have it be displayed in the console. How would i go about doing this?
Thanks.
Welcome to the Java Programming Forums
The professional, friendly Java community. 21,500 members and growing!
The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.
>> REGISTER NOW TO START POSTING
Members have full access to the forums. Advertisements are removed for registered users.
I'm trying to copy my program output to a text file and still have it be displayed in the console. How would i go about doing this?
Thanks.
Use system.out.println() any where you write to your file. Just mirror the printing statements you do to your file with system.out.prints to the console. Simple as that.
I'm not sure i understand what you're saying, I have my program done and it outputs a bunch of text in the console how do i get it to create a text file with that output when the program is run.
Some OSs have command line operators to pipe a program's output into a file. Is that what you are asking about? Do a search for your OS to see what the operator is.
If you don't understand my answer, don't ignore it, ask a question.
Check this link out. It shows you some examples of writing to a text file in java. Multiple ways.
Java - Streams, Files and I/O
i used System.setOut but that redirects the output to the text file and the console is left blank.
Cornix' excellent and helpful response was moved the tutorial section.