Go Back   CodingForums.com > :: Server side development > Java and JSP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 07-03-2008, 08:00 PM   PM User | #1
junior1025
New to the CF scene

 
Join Date: Jul 2008
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
junior1025 is an unknown quantity at this point
Thumbs up Extract filename out of absolute path

Hi,

I got a list of URL's( Absolute Path's) from which I have to return only the list of filenames ( Relative Path's).

Ex:
AbsolutePath -- C:/Programfiles/hello/abc.txt

I need to pull the RelativePath --- abc.txt.

I really appreciate your help.

Thanks.
junior1025 is offline   Reply With Quote
Old 07-03-2008, 10:15 PM   PM User | #2
oracleguy
Rockstar Coder


 
Join Date: Jun 2002
Location: USA
Posts: 9,042
Thanks: 1
Thanked 322 Times in 318 Posts
oracleguy is a jewel in the roughoracleguy is a jewel in the roughoracleguy is a jewel in the rough
We aren't telepaths. You have to give us more information. What language are you using? Do you just want the filename or do you want the relative path from where the code is executing from?
__________________
OracleGuy
oracleguy is offline   Reply With Quote
Old 07-04-2008, 03:50 PM   PM User | #3
Pennimus
Senior Coder

 
Join Date: Jul 2005
Location: UK
Posts: 1,051
Thanks: 6
Thanked 13 Times in 13 Posts
Pennimus is on a distinguished road
If this is a one time thing, just use Excel, and split by "/", or do a wildcard find/replace.
Pennimus is offline   Reply With Quote
Old 07-07-2008, 01:41 PM   PM User | #4
junior1025
New to the CF scene

 
Join Date: Jul 2008
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
junior1025 is an unknown quantity at this point
Iam sorry!

It is in Java.
I need only the files names.

Please tell how todo in either cases.

Thanks.
junior1025 is offline   Reply With Quote
Old 07-07-2008, 04:30 PM   PM User | #5
oracleguy
Rockstar Coder


 
Join Date: Jun 2002
Location: USA
Posts: 9,042
Thanks: 1
Thanked 322 Times in 318 Posts
oracleguy is a jewel in the roughoracleguy is a jewel in the roughoracleguy is a jewel in the rough
Then I will move this over to the Java forum.
__________________
OracleGuy
oracleguy is offline   Reply With Quote
Old 07-07-2008, 06:26 PM   PM User | #6
brad211987
Regular Coder

 
brad211987's Avatar
 
Join Date: Sep 2005
Location: Ohio
Posts: 631
Thanks: 10
Thanked 50 Times in 50 Posts
brad211987 is an unknown quantity at this point
If you have the URLs stored in strings then here are 2 options off the top of my head.

First you could use the split method of the String class to split the url using / as a delimiter.

Otherwise you could use the substring method starting at lastIndexOf('/') +1.
brad211987 is offline   Reply With Quote
Old 07-15-2008, 11:05 PM   PM User | #7
maidenrockdan
New to the CF scene

 
Join Date: Jul 2008
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
maidenrockdan is an unknown quantity at this point
Smile The correct solution

Original post deleted

Last edited by maidenrockdan; 07-15-2008 at 11:06 PM.. Reason: Wrong language
maidenrockdan is offline   Reply With Quote
Old 07-16-2008, 04:39 AM   PM User | #8
shyam
Senior Coder

 
shyam's Avatar
 
Join Date: Jul 2005
Posts: 1,563
Thanks: 2
Thanked 163 Times in 160 Posts
shyam will become famous soon enough
Quote:
Originally Posted by junior1025 View Post
Ex:
AbsolutePath -- C:/Programfiles/hello/abc.txt

I need to pull the RelativePath --- abc.txt.
you mean the filename...
Code:
String path = "C:/Programfiles/hello/abc.txt";
String fileName = new File(path).getName();
__________________
You never have to change anything you got up in the middle of the night to write. -- Saul Bellow
shyam is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 07:03 AM.


Advertisement
Log in to turn off these ads.