file.lastModified() not working in MAC OS
Hi all,
Iam trying to get the lastmodified time of a file using this
File newFile=new File(uploadFilePath);//uploadFilePath has the path of the file.
String newFile_Name=newFile.getName();
long lastmodified=newFile.lastModified();
The above is working in windows but not in MAC. in MAC i get the lastmodified time as 0. I
s there anyother functionality to get this in MAC. or is it the problem with the path?.
For eg. theuploadFilePath in PC will be like this
C:\Documents and Settings\Tanuja\Desktop\File\file_management.txt
where as in MAC file path of a selected file will be like this.
/Users/Tanuja/Desktop/file_management.txt
is this path makes difference or iam i going wrong somewhere?
could not figure out.
Thanks,
Thanuja.
[946 byte] By [
thanua] at [2007-11-27 10:14:58]

# 1
I found where the problem is. Using the file chooser i selected a file and got the file path and my code deals witht the path as below:
String uploadFilePath=/Users/Tanuja/Desktop/file_management.txt
File newFile1=new File(uploadFilePath);
//Check whether file exists or not
if(newFile1.exists()==true)
out.println("exists");
else
out.println("does not exists");
Result: does not exists
So i tried by passing the absolute path but all in vain. I get the same result.
Absolute path: C:\Users\Tanuja\Desktop\file_management.txt
String uploadFilePath=/Users/Tanuja/Desktop/file_management.txt
File newFile1=new File(uploadFilePath);
String abslolutePath=newFile1.getAbsolutePath();
File newFile=new File(abslolutePath);
if(newFile.exists()==true)
out.println("exists");
else
out.println("does not exists");
why its not detecting the file though the file path it returned is correct?.
since it is not detecting the file i got the lastmodified as 0.
iam using commons upload to upload the file. how commons package is able to detect the file and upload. My upload process is success. but before uploading the file i need to validate it by gettting the lastmodified date. Its not working.
Any suggestions?
Thanks,
Thanuja.
thanua at 2007-7-28 15:36:39 >
