943,824 Members | Top Members by Rank

Ad:
  • Java Discussion Thread
  • Marked Solved
  • Views: 772
  • Java RSS
Dec 8th, 2008
0

Split a line?

Expand Post »
Okay im reading in lines of text e.g "abcdefg" and I need to split the line into an array of characters where each character is stored in its own element so its like [a][b][c][d][e][f][g]

I know how to do it with splitting words from poems etc... using something like txtLine.split(" ") but i dont know how to do it with thse characters. They have no spaces between them?
Similar Threads
Moderator
Featured Poster
Reputation Points: 1764
Solved Threads: 574
Moderator
jbennet is offline Offline
16,510 posts
since Apr 2005
Dec 8th, 2008
0

Re: Split a line?

read it as a String and use the toCharArray() method
Reputation Points: 935
Solved Threads: 356
Nearly a Posting Maven
stultuske is online now Online
2,497 posts
since Jan 2007
Dec 8th, 2008
0

Re: Split a line?

This was also mentioned by myself and s.o.s. two days ago in your other post about the char array...
Moderator
Featured Poster
Reputation Points: 3239
Solved Threads: 839
Posting Genius
Ezzaral is offline Offline
6,761 posts
since May 2007
Dec 8th, 2008
0

Re: Split a line?

yeah i just managed to get it working. Thanks all!
Moderator
Featured Poster
Reputation Points: 1764
Solved Threads: 574
Moderator
jbennet is offline Offline
16,510 posts
since Apr 2005
Dec 9th, 2008
0

Re: Split a line?

One of the important things you should know as a Java developer is to find the classes in the standard library which contain the functionality you desire. As an example, since you need to operate on Strings and need to generate a char array, looking into the documentation of String and Character classes should be your first step. If that fails, try looking into the java.util package for utility methods which operate on your data. If you need help with text processing and formatting, java.text package should be good to go. This is a pretty good exercise and will actually make you aware of the functionality provided by the Java standard library.

If that fails, use your favorite search engine to give you a solution to your problem. In your case, searching for 'convert string to char array' hit the spot right on.

When everything fails, use discussion groups as your last resort. It's not too much work, really, and if you feel it is, then think that it for your own good. :-)
Super Moderator
Featured Poster
Reputation Points: 3233
Solved Threads: 719
Failure as a human
~s.o.s~ is offline Offline
8,871 posts
since Jun 2006

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

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: I have tried to set a label to change its text at each time.
Next Thread in Java Forum Timeline: please suggest





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


Follow us on Twitter


© 2011 DaniWeb® LLC