• Post Reply Bookmark Topic Watch Topic
  • New Topic

String Parsing Help  RSS feed

 
Bhavesh Thakkar
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I am getting a string from database of type varchar(998) , what i want to do is to break this string up into different tokens based on its length.

Lets say for example i am having 10 fields on my screen, then i want to assign the first two chracters of the String to the first field, next 10 to the second field and so n and so forth.

e.g Field 1 ( 2 characters out of the 998 chracters long string)
Field 2 ( next 10 characters )
..
..

can anyone of you provide me up with some kind of sample code for the same.

Thanks in advance!!
Bhavesh Thakkar
 
Shashi Kant
Ranch Hand
Posts: 117
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bhavesh

You can use the methods from Sting class like

which returns a new string that is a substring of this string.
For more help you can check the methods from String class

Hope this hepls you

All the Best
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Shashi Shashi",
Welcome to the JavaRanch.

We're a friendly group, but we do require members to have valid display names.

Display names must be two words: your first name, a space, then your last name. Fictitious names are not allowed.

Please edit your profile and correct your display name since accounts with invalid display names get deleted, often without warning

thanks,
Dave
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!