DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 2 of 2
  1. #1
    Join Date
    Mar 2005
    Location
    London
    Posts
    18

    test whether a file exists

    Hello all,

    I'm developing an application designed to return records along with any associated images. The images will be named after the records primary key; ie "102.jpg". I'm going to display the full record information on one jsp and provide a link to another jsp to display the image, via a button/link whatever.

    The problem is that not all records have associated images and I have to engineer the system such that the link appears ONLY when an image is present in the img directory. How can I test at runtime whether file 102.jpg is present?

    Thanks!

  2. #2
    Join Date
    Mar 2004
    Posts
    635
    File file = new File("images/102.jpg");

    if (file.exists())
    //file exists

Similar Threads

  1. Check if file exists
    By John Knoop in forum .NET
    Replies: 8
    Last Post: 02-28-2010, 01:57 PM
  2. Replies: 1
    Last Post: 04-01-2002, 04:41 PM
  3. file name==class name. why?
    By siva in forum Java
    Replies: 2
    Last Post: 01-03-2001, 10:40 AM
  4. Read a test file in.
    By Jeff in forum Java
    Replies: 0
    Last Post: 11-08-2000, 12:57 PM
  5. Replies: 3
    Last Post: 05-31-2000, 10:30 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links