944,153 Members | Top Members by Rank

Ad:
  • Java Discussion Thread
  • Unsolved
  • Views: 4954
  • Java RSS
Sep 3rd, 2006
0

String Splitter

Expand Post »
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"
Similar Threads
Reputation Points: 14
Solved Threads: 0
Newbie Poster
im4tion is offline Offline
7 posts
since Sep 2006
Sep 3rd, 2006
0

Re: String Splitter

What about using the .toCharArray() method on String?
Reputation Points: 11
Solved Threads: 8
Posting Whiz in Training
hooknc is offline Offline
216 posts
since Aug 2005
Sep 3rd, 2006
0

Re: String Splitter

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.
Reputation Points: 14
Solved Threads: 0
Newbie Poster
im4tion is offline Offline
7 posts
since Sep 2006
Sep 5th, 2006
0

Re: String Splitter

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/
Reputation Points: 92
Solved Threads: 51
Practically a Posting Shark
Phaelax is offline Offline
856 posts
since Mar 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Java Forum Timeline: adding an image to a java code
Next Thread in Java Forum Timeline: how to move an jlabel icon from one jlabel to another jlabel





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC