java - how to replace filepath ,In that filepath delete some path and also replace \ to / -
fi.write(file); out.println("filepath"+file.getabsolutepath()); system.out.println("above actual paht , bellow replace path"); string propic = file.getabsolutepath(); hpiugs.setimagename(propic); system.out.println(hpiugs.getimagename()); out.println("uploaded filename: " + filename + "<br>"); out.println(filepath);
output :
c:\users\peado inffitech 5\desktop\eclipse\jsp\userspanel\upload\uploadspenguins.jpg
where change output as:
/jsp/userspanel/upload/uploadspenguins.jpg
string gotstring = "c:\\users\\peado inffitech 5\\desktop\\eclipse\\jsp\\userspanel\\upload\\uploadspenguins.jpg"; string newstring = gotstring.replace("c:\\users\\peado inffitech 5\\desktop\\eclipse", "").replace("\\", "/"); system.out.print(newstring);
this should work if not missing out point horribly.
Comments
Post a Comment