Reputation: 21
I need to make a JTextArea
that takes in a text document of votes, which are just 'y' and 'n', using a BufferedReader
given to me by my professor; and it needs to count the 'y' and 'n' characters within that first row and for each row after. He gave the class a hint that an array would be useful, but I'm not sure how to do this and any help would be greatly appreciated. Thanks!
Edit: This is not really a homework assignment, but I need to know how to do this by tonight so I can actually be able to implement it for my final, which is tomorrow.
Upvotes: 1
Views: 448
Reputation: 205775
You'll find suitable examples in the article How to Use Text Areas.
Addendum: A thoughtful observer asks,
What would be the code to get the text in a single row?
BufferedReader
may be good choice, as suggested in this example that copies stdin
to stdout
:
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
String s;
while ((s = in.readLine()) != null) {
// process s
}
Upvotes: 2