How to Read from Console and File in a program!
posted 15 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Hi guys !
Could you please let me know how I can make the Scanner object read String like password from file and check it with user input from console?!
I tried to use one scanner object which I got error.
thanks
Could you please let me know how I can make the Scanner object read String like password from file and check it with user input from console?!
I tried to use one scanner object which I got error.
thanks
posted 15 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Sure, but we ask that you ShowSomeEffort and DoYourOwnHomework. What have you tried so far?
posted 15 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Which error did you get? TellTheDetails.
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
Behrouz Hosseini
Ranch Hand
Posts: 31
posted 15 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Yeah , this is the code which I was talking about it
as you can see I have two Scanner object (filePass and inputPass) but system try o read both of them by FileInputStream class which id not desierd
as you can see I have two Scanner object (filePass and inputPass) but system try o read both of them by FileInputStream class which id not desierd
Behrouz Hosseini
Ranch Hand
Posts: 31
posted 15 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
This is the error/ Exception
posted 15 years ago
Are you sure you want to reassign the standard input stream? I'll answer this for you: you really don't want to do this.
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Behrouz Hosseini wrote:
Are you sure you want to reassign the standard input stream? I'll answer this for you: you really don't want to do this.
Behrouz Hosseini
Ranch Hand
Posts: 31
posted 15 years ago
what do you mean?
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
pete stein wrote:
Behrouz Hosseini wrote:
Are you sure you want to reassign the standard input stream? I'll answer this for you: you really don't want to do this.
what do you mean? posted 15 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
System.in is now pointing to a text file that apparently only has one line. To read from both the file and the console use "new Scanner(new File("D:/Java/test.txt"))" as well as "new Scanner(System.in)". This will give you two Scanner objects. You currently don't; filePass and inputPass are not Scanner objects but Strings, and keyboard is your only Scanner object.
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
Behrouz Hosseini
Ranch Hand
Posts: 31
posted 15 years ago
Thanks Rob,
I got it, so I had to create two objects of Scanner,
perfect it's working now
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Rob Prime wrote:System.in is now pointing to a text file that apparently only has one line. To read from both the file and the console use "new Scanner(new File("D:/Java/test.txt"))" as well as "new Scanner(System.in)". This will give you two Scanner objects. You currently don't; filePass and inputPass are not Scanner objects but Strings, and keyboard is your only Scanner object.
Thanks Rob,
I got it, so I had to create two objects of Scanner,
perfect it's working now
posted 15 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
You're welcome.
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
| And then the entire population worshiped me like unto a god. Well, me and this tiny ad: The new gardening playing cards kickstarter is now live! https://www.kickstarter.com/projects/paulwheaton/garden-cards |









