Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

I am missing something regarding redirection and Stream

835847Feb 24 2011 — edited Feb 27 2011
Using Scanner, am I able to redirect on the fly? I am familiar with redirection in C. Is redirection in Java similar? Do I have to redirect in the following manner:
java myprogram < mytestfile.txt
or can I redirect on the fly with Scanner?

Also, is end of file in Java the same as when I provide Scanner input and hit return?

What I desire to do is allow both console use and redirection. If the user prefers redirection, then my program will use Scanner and StringTokenizer to parse each line of the file, ignoring /n and sending a long concatenated string as input further along. If the user prefers console, then I have a method that will read a file and the program continues.

Edited by: 832844 on Feb 24, 2011 8:29 AM
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 27 2011
Added on Feb 24 2011
64 comments
563 views