| | |
Split a line?
Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved |
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?
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?
If i am helpful, please give me reputation points.
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
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. :-)
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. :-)
I don't accept change; I don't deserve to live.
![]() |
Similar Threads
- help -- my for loop only does one line? (Python)
- How to count a split occurence from a file (Python)
- how to read a new line in my text file (C#)
- Split text and store it in arraylist [ problem with code] (Java)
- Reading a text file character by character and line by line (C++)
- How to skip a line ! (Perl)
- Reading specific line in a file. / Searching (C++)
- [help] Split word in Java (Java)
- Finding a number in a line (Perl)
- Ignoring the rest of a line (Perl)
Other Threads in the Java Forum
- Previous Thread: I have tried to set a label to change its text at each time.
- Next Thread: please suggest
| Thread Tools | Search this Thread |
actuate android api applet application applications array arrays automation balls bank binary bluetooth business chat class classes clear client code codesnippet collections component database db defaultmethod development dice dragging ebook eclipse error event exception formatingtextintooltipjava fractal game givemetehcodez graphics gui hql html ide image infinite input integer invokingapacheantprogrammatically j2me java javaprojects jni jpanel julia linux list loop looping map method methods mobile mysql netbeans newbie numbers openjavafx oracle parameter php print problem program programming project recursion repositories scanner screen scrollbar server set size sms sort sorting sql sqlserver state storm string sun superclass swing swt text-file threads time tree windows






