Counting number of characters entered by user at console window
Posted on 2005-03-28
Thanks in advance for any help.
I'm trying to get the number of characters a user has typed. I tried the following:
public class BufferSize
public static void main(String args)
int numChars = 0;
BufferedInputStream in = new BufferedInputStream(System.in);
catch (IOException e)
numChars = in.count;
System.out.printf("Number of characters: \n", numChars);
The compiler gripes that count is a protected member of BufferedInuputStream class. Now, I thought that protected meant that if I created
an instance of the class, then my instance would have access to the variable. Some clarification on this would be helpful as well as
any advice on getting that character count with or without using the BufferedInputStream.