public static void main(String[] args) throws Exception {
System.out.println("Enter");
BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
{
int c;
int count = 0;
while ((c = input.read()) != -1) {
System.out.println(+count);
count++;
}
}
}
Using the read() method only I want to print the count of each char, Eg: if my input:the star then output should be: 9, but when I try to put the count outside the loop my program never comes out of loop and print the total count value, readline(), next(), hasnext() methods doesn't count char by char so they give me a wrong result