guys, I'm trying to read a stream of numbers from standard input like: 2 3 -3 10 44 9 -1. The line ends once it read -1, but for some reason I have an endless loop... how could I read this stream of numbers one number at a time?
int num[] = new int[5]; char ch; BufferedReader bf = new BufferedReader(new InputStreamReader(System.in)); System.out.println("enter series of number: "); int i = 0; do{ num[i] = bf.read(); i++; }while(num[i] != -1); int j = 0; while(j < num.length) { System.out.println(num[j]); j++; }