Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to read characters from a string ?

 
Rohit Prakash Khare
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
In my java program I accepted string from the user and now I want to calculate the length of the string, and then read characters one by one to encrypt it.
How to read the characters one by one ? Like Mid$ function in VB.
 
arun mahajan
Ranch Hand
Posts: 305
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To find the length of string use length() method AND THAN RUN IT IN A for loop fo charter finding perhaps folowin code willhelp:

hope it may help...
Arun
 
Rohit Prakash Khare
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Arun, I will sure try.
 
John Loney
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Another approach similar to the $mid is
substr(int begpos,int endpos) in a for loop
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic