aspose file tools
The moose likes Java in General and the fly likes How to use a Scanner in a bean? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "How to use a Scanner in a bean?" Watch "How to use a Scanner in a bean?" New topic
Author

How to use a Scanner in a bean?

Paul Adcock
Ranch Hand

Joined: Jan 22, 2011
Posts: 34

I tried using a Scanner to scan a text file, but despite putting it right in the source folder, ti says it can't find the file. Am I doing something wrong or are beans not allowed to use Scanners?

It seems to only work with an absolute path but I can't give it one if I intend to make it a jar file.

I've placed copies of the file in all sorts of spots in the Nebeams project but it simply can't find it, despite being able to see it from the files window under the projects part in the src package part.



Right now I have it having the user ask for the directory, but that is a pain for the user. However, it will work if I do that.


Hi all.
Greg Charles
Bartender

Joined: Oct 01, 2001
Posts: 2537
    
  10

You need to be a bit clearer. You're trying to read a file that's in a jar file? Is that the file it says it can't find? I assume the bean you mean is a JSF managed bean, and thus the connection to JSF, but I don't think you're issue is with JSF, so I'll move this over to our General Java forum.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to use a Scanner in a bean?
 
Similar Threads
Reading a text file records separated by a ';'
Exception error? Please help, frustrating
InputStreamReader
Use of Scanner and Text files
How to Read from Console and File in a program!