// JP opened flex table

Click to See Complete Forum and Search --> : File exception in applet


szheli
June 1st, 2000, 02:54 PM
I am writing an appliet which retrieves the lastModidfied time of an image file located on the same location as the applet. I created a File object with the URL to the file, and tried to call a member method such as lastModified(), I get an exception. If I test it on my local machine, it works, if I run it over the network on a web server, the exception occurs. here is the code, I appreciate any comments.

String path = "http://webs1/nr/assembly/childcarecam/ChildCareImages/ccc1.jpg";


File image_file = new File(path);
showStatus(path);

boolean exist = image_file.exists();//exception
showStatus("file time retrieved");
long creation_time = image_file.lastModified();

kib63613
June 1st, 2000, 07:37 PM
You may try to get the LastModified information by the method getLastModified() of the class
URLConnection. You can do it like this :
URL url = new URL("http://www.web.com/path/webpage.jpg");
URLConnection url_conn = url.openConnection();
long date = url_conn.getLastModified();

This information is recorded in the header of web page. I am not sure if it works, or it satisfies your
need. But I think that it might be the possible way that you can try.
good luck,
Alfred Wu

Lynx
June 1st, 2000, 07:40 PM
You need to make a URL connection to the server and download the file to the Applet. then you cna do whatever you want, except to write the file to user's hard drive which requires user's permission.
you try the following:


URL url = new URL("http://webs1/nr/assembly/childcarecam/ChildCareImages/ccc1.jpg");
URLConnection urlConnection = url.openConnection();
long creation_time = urlConnection.getLastModified();
// ......





HTH

Lynx

//JP added flex table