How to split a string having string as delimiter instude of char?
843829Dec 21 2001 — edited Dec 21 2001Hello 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