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 | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Java in General
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: 48

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.


Repeal Obamacare.
http://www.dontfundobamacare.com/
http://liberty-amendments.freeforums.net/
Greg Charles
Sheriff

Joined: Oct 01, 2001
Posts: 2864
    
  11

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?