File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes I/O and Streams and the fly likes [SOLVED] Using FilenameFilter inline with JSP? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "[SOLVED] Using FilenameFilter inline with JSP?" Watch "[SOLVED] Using FilenameFilter inline with JSP?" New topic
Author

[SOLVED] Using FilenameFilter inline with JSP?

B. Katz
Ranch Hand

Joined: Aug 28, 2009
Posts: 50

Greetings,

I've been working on what I thought should be a simple issue, but it's been driving me nuts for 2 days. :-P Doh!

What I need is:
  • To take the name of a file that is being passed from another page.
  • Check it against the filesystem, regardless of case.
  • Return the name of the file that is in the filesystem that matches the passed filename, Upper/Lower-case notwithstanding.


  • What I have so far is:


    And, of course, this returns *everything* in that directory. If I try to use a passed-in variable, I get "Cannot refer to a non-final variable procname inside an inner class defined in a different method"

    So, is there a simple way to get the FilenameFilter to do the comparison for me, or do I have to keep checking against the String Array it produces?

    TIA.


    "I do not feel obliged to believe that the same God who has endowed us with sense, reason, and intellect has intended us to forgo their use."
    -- Galileo Galilei
    Bear Bibeault
    Author and ninkuma
    Marshal

    Joined: Jan 10, 2002
    Posts: 60059
        
      65

    Moved to the I/O forum as it has little to do with JSP.

    I still find it hard to believe that people still put Java code in a JSP in 2011.


    [Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
    Paul Clapham
    Bartender

    Joined: Oct 14, 2005
    Posts: 18140
        
        8

    B. Katz wrote:If I try to use a passed-in variable, I get "Cannot refer to a non-final variable procname inside an inner class defined in a different method".


    And what happened when you declared "procname" final?

    Edit: never mind, I see what happened. You want this:


    Or better, if the parameter value is null then there's no point in executing all of that code so just use an if-statement.
    B. Katz
    Ranch Hand

    Joined: Aug 28, 2009
    Posts: 50

    Thanks folks.

    That did it! And, it once again proves that old adage of programming; "The longer you work on a problem, the simpler the resolution will be."

    @Paul: If we get to that page, then there shouldn't be any way that procname would be empty or null, but I don't count on that. Thanks much!

    And, @Bear: I was not the one who started the project, but it is in my hands to support it until we can get it switched to something more current (READ: more inline with current standards.).
    Ummm... I'll just leave it at that. ;-p hehe

    Thanks again.
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: [SOLVED] Using FilenameFilter inline with JSP?
     
    Similar Threads
    List of Files
    filenameFilter in linux directory
    help moderator or site admin
    The method list(FilenameFilter) in the type File is not applicable for the arguments (FilenameFilter
    Problem with ArrayList .contains() method