aspose file tools
The moose likes Beginning Java and the fly likes How to read characters from a string ? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "How to read characters from a string ?" Watch "How to read characters from a string ?" New topic
Author

How to read characters from a string ?

Rohit Prakash Khare
Greenhorn

Joined: Jun 09, 2002
Posts: 6
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.


"As long as there are tests, there will be prayer in public <br />schools."
arun mahajan
Ranch Hand

Joined: Dec 07, 2001
Posts: 304
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

Joined: Jun 09, 2002
Posts: 6
Thanks Arun, I will sure try.
John Loney
Greenhorn

Joined: Jun 03, 2002
Posts: 4
Another approach similar to the $mid is
substr(int begpos,int endpos) in a for loop
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: How to read characters from a string ?
 
Similar Threads
how to read character from command line and store it string
Calling correct methods
identify and replace special character
what is the limitation of getString(column name)?
Magnetic Card Swipe Reader input to Console