wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes How to read characters from a string ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
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: 305
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://aspose.com/file-tools
 
subject: How to read characters from a string ?
 
Similar Threads
how to read character from command line and store it string
Calling correct methods
what is the limitation of getString(column name)?
identify and replace special character
Magnetic Card Swipe Reader input to Console