test whether a file exists


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: test whether a file exists

  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, 02:57 PM
  2. Replies: 1
    Last Post: 04-01-2002, 05:41 PM
  3. file name==class name. why?
    By siva in forum Java
    Replies: 2
    Last Post: 01-03-2001, 11:40 AM
  4. Read a test file in.
    By Jeff in forum Java
    Replies: 0
    Last Post: 11-08-2000, 01:57 PM
  5. Replies: 3
    Last Post: 05-31-2000, 11:30 AM

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


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center