-
Please help
Dera All,
Please help me as this is urgent that i need to fix:
The value of each token should be the value between two consecutive token(|).So
in the example below the value of token after msg[0]
should be
"error: cannot insert NULL into the emp table) change the values errorcode
is 1111 msg is aa"
My file is as follows:
Name|john|
|robert|
|smith|
|ruby|
msg[0]|error: cannot insert NULL into
(the emp table) change the values
errorcode is 1111
msg is aa
|
city[0]|boston|
phone[0]|5555555555|
|8888888888|
|0|
|0|
The output should be
Name
john
robert
smith
ruby
msg[0]
error: cannot insert NULL into (the emp table)change the values errorcode
is 11msg is aa
city[0]
5555555555
8888888888
0
0
what changes should i make to the code below so that if the error message
spans multiple lines then all those lines should be printed as 1 token
StringBuffer StringBuf = new StringBuffer();
String line = null;
while ((line = in.readLine()) != null) {
StringBuf.append(line + "\n");
}
String cString = StringBuf.toString();
StringTokenizer tokenizer = new
StringTokenizer(cString, "\n");
while (tokenizer.hasMoreTokens()) {
currentRecord = tokenizer.nextToken();
if (currentRecord.length() > 0) {
token = new StringTokenizer(currentRecord, "|");
String s = token.nextToken().trim();
System.out.println("the string is" +s);
while (token.hasMoreTokens()) {
String testtoken=(String)token.nextToken();
System.out.println("the tetstoken is " +testtoken);
}
Thanks,peter
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks