hi all there !
I have problem with java file object that when ever i want to delete a file from the server i have check whether its exist or not for this i get fileObject.getAbsolute path but it return me wrong path but i get path from db a give to file object although it give to error no file exist

my code the below

Thanks to in advance if not mind ?

<%
// out.println("B4 try sk");
ResultSet rst=null;
ArrayList imgPath=new ArrayList();
ArrayList imgNam=new ArrayList();
//cUser is current user who log on to system

try{
String query ="Select * from imageinfo where userName like'%" + cUser +"%'";
rst=db.ExecuteQuery(query);
}
int count=1;
while(rst.next())
{
imgPath.add(rst.getString("imagePath"));
imgNam.add(rst.getString("imgName"));
count++;
}//end while loop

String usrid=session.getAttribute("usr").toString();
String serverFolder="D:\\";
String imgID=request.getParameter("p1");
String usrID=null;
String location1=null;
for(int ii=0;ii<imgPath.size();ii++)
{
// usrID="\\"+usrid+"\\"+"\\"+imgFold.get(ii).toString()+"\\";
location1= imgPath.get(ii).toString()+"\\"+imgNam.get(ii).toString();
File fi=new File(location1);
//out.println("Cononical Path \t"+fi.getCanonicalPath());
// File newfile=new File(fi.getCanonicalPath());
out.println("Cononical Path \t"+fi.getPath());
if(fi.exists())
{
boolean success;
out.println("SuccessFull");
// String fipath=fi.getAbsolutePath();
success= fi.delete();
out.println(success);
}
else
{
out.println(" file at \t"+location1+"\t does not exist");
}
}

out put it generated is "Cononical Path C:\Documents and Settings\shahbaz\jbproject\skpiat1\Tomcat\ D:\shahbaz\Family \Eyes.jpg "
But actual path is "Path from db is D:\shahbaz\Family \Eyes.jpg "

plz plz get me out of this horrible daemon

Thanks adata for repling but it will not give me real path its allow me only absolute or cononical path which give not accurate path

I did't get you about real path. Do you want to a path of file or folder in your web application?

I did't get you about real path. Do you want to a path of file or folder in your web application?

Thanks for reply :
dear i pass a path that come from mysql like
"D:\shahbaz\Friends \abc.JPG"
to file object .
When get path from object to check file exist on path or not ; file object return me false.
and when i try to getabsolutepath or getcononicalpath it give me
output like this
"C:\Documents and Settings\shahbaz\jbproject\skpiat1\Tomcat\ D:\shahbaz\Friends \1.JPG"

how do get exact path up to folder in D:\\ drive

hi adata !

In short i want file object return me this path inorder to get absolute path ( D:\shahbaz\Friends \1.JPG) which i give it to file object instead of this
("C:\Documents and Settings\shahbaz\jbproject\skpiat1\Tomcat\ D:\shahbaz\Friends \1.JPG")

This article has been dead for over six months. Start a new discussion instead.