Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

reading strings

Status
Not open for further replies.

yama

Programmer
Jun 28, 2001
69
SG
Hi, i have a small problem and i hope someone can help me out =)
I had retrieve a string of a file path -->> /images/product/pic.gif and want to display it in a textbox on a form as pic.gif without the /images/product.
Is there any way to do this?
Thanks!!
 
Try this:
Code:
<%
String path = &quot;/images/product/pic.gif&quot;;
String filename = null;
int i = path.lastIndexOf('/');
if (i != -1) {
  filename = path.substring(i+1);
}
else {
  filename = new String(path);
}
out.println(&quot;File is &quot; + filename);
%>
Wushutwist
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top