|
How to read a String line by line |
|
|
Assume that you have a text area and you want to process its content line by line. In such a case you can easily use StringReader class.
The follwoing example shows how to print the first character of each line of a textarea content:
String str;
BufferedReader reader = new BufferedReader(
new StringReader(contentTextArea.getText()));
try {
while ((str = reader.readLine()) != null) {
if (str.length() > 0) System.out.println(str.charAt(0));
}
} catch(IOException e) {
e.printStackTrace();
}
|
Related Tips
|
Page 1 of 0 ( 0 comments )
You can share your information about this topic using the form below!
Please do not post your questions with this form! Thanks.