Skip to Main Content

Java HotSpot Virtual Machine

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

How to split a string having string as delimiter instude of char?

843829Dec 21 2001 — edited Dec 21 2001
Hello Gurus,

I want to split the string and work on each split string.

The following code will do, but not exactly.
It's split into morethan three strings, where coma find.
But I want to split it using #,# as delimiter.

Here is my code:
//File fileData = new File("myfile.txt");
// This will have coma separated fields data
// while traversing this file will readLine() give the string, that is strRecord

// BufferedReader bfrdRdrObj = new BufferedReader(new FileReader(strDataFile));
//while ((strThisLine = bfrdRdrObj.readLine()) != null) {..........

String strRecord = #A001#,#User1#,#this is record, so need to split and place, insert into table#;

StringTokenizer strTknRec = new StringTokenizer(strRecord,"#,#");
int iCounter=0;
while(strTknRec.hasMoreTokens()){
System.out.println(++iCoutner+"Field: "+strTknRec.nextToken());
}


Please, give me hint.

Thanks in advance.

~ SubbaReddy .M
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 18 2002
Added on Dec 21 2001
2 comments
162 views