I just tried your code and it works fine*. Please provide more details as to exactly what you are seeing.
*although it does need to be surrounded by a
try/catch
sequence to check for
IOException
.
[edit]
I am still not exactly sure what your problem is, but the following code will allow up to 20 characters to be processed. It will terminate on the end of line.
BufferedReader br= new BufferedReader (new InputStreamReader(System.in));
char a [] = new char [20];
int count;
try {
for (count = 0; count < 20; count++) {
char n = (char)br.read();
if (n == '\n')
break;
a[count] = n;
}
for (int i = 0; i < count; i++) {
System.out.println ( a[i]);
}
}
catch (IOException ee) {
System.out.println (ee);
}
[/edit]