Board index » jbuilder » How to split a String?

How to split a String?


2005-04-19 04:06:42 PM
jbuilder11
I want to get "14.pdf" from string "d:\uintapp\search\info\14.pdf",
but how to implement?
my jdk is 1.3
Thanks
Century
 
 

Re:How to split a String?

csicentury wrote:
Quote
I want to get "14.pdf" from string "d:\uintapp\search\info\14.pdf",
but how to implement?
my jdk is 1.3

Thanks
Century


I guess the only cross-platform implementation is
String path = "d:\uintapp\search\info\14.pdf";
String name = new File( path ).getName();
This should return at least an empty string (if path has no filename).
- Vander
 

Re:How to split a String?

csicentury wrote:
Quote
I want to get "14.pdf" from string "d:\uintapp\search\info\14.pdf",
but how to implement?
my jdk is 1.3

Thanks
Century
Asked and answered in another newsgroup. Please don't cross-post.
--
Kevin Dean [TeamB]
Dolphin Data Development Ltd.
www.datadevelopment.com/
NEW WHITEPAPERS
Team Development with JBuilder and Borland Enterprise Server
Securing Borland Enterprise Server
www.datadevelopment.com/papers/index.html
Please see Borland's newsgroup guidelines at
info.borland.com/newsgroups/guide.html
 

{smallsort}

Re:How to split a String?

Vander wrote:
Quote
csicentury wrote:

>I want to get "14.pdf" from string "d:\uintapp\search\info\14.pdf",
>but how to implement?
>my jdk is 1.3
>
>Thanks
>Century
>
>

I guess the only cross-platform implementation is

String path = "d:\uintapp\search\info\14.pdf";
String name = new File( path ).getName();

This should return at least an empty string (if path has no filename).

- Vander
String.substring() with String.lastIndexOf( File.separatorChar ) should
work.
--
Regards,
Lori Olson [TeamB]
------------
Save yourself, and everyone else, some time and search the
newsgroups and the FAQ-O-Matic before posting your next
question.
Google Advanced Newsgroup Search
www.google.ca/advanced_group_search
Other Newsgroup Searches:
www.borland.com/newsgroups/ngsearch.html
Joi Ellis's FAQ-O-Matic:
www.visi.com/~gyles19/fom-serve/cache/1.html
 

Re:How to split a String?

Lori M Olson [TeamB] wrote:
Quote
String.substring() with String.lastIndexOf( File.separatorChar ) should work.
Provided you handle the -1 case (no separator char)..
 

Re:How to split a String?

Thanks
Century
"Shankar Unni" < XXXX@XXXXX.COM >
??????: XXXX@XXXXX.COM ...
Quote
Lori M Olson [TeamB] wrote:

>String.substring() with String.lastIndexOf( File.separatorChar ) should
work.

Provided you handle the -1 case (no separator char)..