Results 1 to 2 of 2
Thread: How to use delimiter in java
- 02-12-2010, 09:25 PM #1
Member
- Join Date
- Feb 2010
- Posts
- 4
- Rep Power
- 0
How to use delimiter in java
Hello Friends,
I want to use some demiliter functionality in a class i am writing. I have a path: /net/lock/vol/netsys/homes/asirohi/spins/7.1a/XN/server_install.xml, i want to delimit this String by "/" and get the 1st field and the last field. So the output should be: net server_install.xml..
How do i go about, i need ideas or some example program.
Thanks
Aditya
- 02-12-2010, 10:01 PM #2
Senior Member
- Join Date
- Jul 2009
- Posts
- 1,143
- Rep Power
- 5
Use String.split. It will return an array containing each token. Then you take the first and last elements from the array.
Or you could create your own simple routine using methods from the String class. You use the indexOf() method to find the first occurrence of the delimiter and then substring(...) out the text. Then you use the lastIndexOf() method to find the last delimeter and substring out the last token.
Either way you can start by reading the String API for methods to help you.
Similar Threads
-
How do you Use Backslash as a Delimiter?
By Mobius-1 in forum New To JavaReplies: 3Last Post: 12-14-2009, 12:39 AM -
Delimiter question
By Kangaroo128 in forum New To JavaReplies: 10Last Post: 09-09-2009, 09:28 AM -
Use of Scanner class and Delimiter
By tjhodge in forum New To JavaReplies: 3Last Post: 02-12-2009, 05:26 PM -
using Delimiter with metacharacters
By wntdaliv in forum New To JavaReplies: 10Last Post: 12-02-2008, 06:42 AM -
delimiter
By satin in forum New To JavaReplies: 2Last Post: 11-17-2008, 10:50 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks