String Splitter

Reply

Join Date: Sep 2006
Posts: 7
Reputation: im4tion is an unknown quantity at this point 
Solved Threads: 0
im4tion im4tion is offline Offline
Newbie Poster

String Splitter

 
0
  #1
Sep 3rd, 2006
Hi. I was wondering if anyone knows how to split a string. I did find a code on it; but it's based on a pattern.
Can anyone help me to split a string into letters..
e.g. "Like" --> "L", "i", "k", "e"
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 216
Reputation: hooknc is an unknown quantity at this point 
Solved Threads: 8
hooknc hooknc is offline Offline
Posting Whiz in Training

Re: String Splitter

 
0
  #2
Sep 3rd, 2006
What about using the .toCharArray() method on String?
Reply With Quote Quick reply to this message  
Join Date: Sep 2006
Posts: 7
Reputation: im4tion is an unknown quantity at this point 
Solved Threads: 0
im4tion im4tion is offline Offline
Newbie Poster

Re: String Splitter

 
0
  #3
Sep 3rd, 2006
Mm..I found a way using Tokens. But does anyone now know like..taking in blanks, apostrophe, exclamation mark etc. and printing it out again?

Truth is; I'm trying to do a simple encryption method.
e.g. FLEE!! would be equals to NZAA!!
I've managed to split the words and change it but I do not know how to carry the !! or ' forward and output it..Anyone can help?
Currently for changing the output into a simple encryption I'm using if..else. If anyone has a better suggestion please comment
Last edited by im4tion; Sep 3rd, 2006 at 2:23 pm.
Reply With Quote Quick reply to this message  
Join Date: Mar 2004
Posts: 763
Reputation: Phaelax is on a distinguished road 
Solved Threads: 38
Phaelax Phaelax is offline Offline
Master Poster

Re: String Splitter

 
0
  #4
Sep 5th, 2006
Tokens? If you're using StringTokenizer, don't. Use the .toCharArray() method that hooknc mentioned.

Loop through each character using a FOR loop and determine if it's either a letter that should be changed or a symbol that should stay the same. You can do this by checking the characters' ASCII value.

int ascii = (int)character

if ((ascii > 64) && (ascii < 91))
//the character is between capital A and capital Z


You can use this link to see what number ranges alpha-numeric characters are in.
http://www.lookuptables.com/
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Java Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC