• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

[SOLVED] Using FilenameFilter inline with JSP?

 
Ranch Hand
Posts: 58
MyEclipse IDE Chrome Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
     
    Sheriff
    Posts: 67747
    173
    Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    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.
     
    Marshal
    Posts: 28226
    95
    Eclipse IDE Firefox Browser MySQL Database
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator

    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
    Posts: 58
    MyEclipse IDE Chrome Linux
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    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.
     
    With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
    reply
      Bookmark Topic Watch Topic
    • New Topic