Click to See Complete Forum and Search --> : TextArea()


Anna Chou
September 23rd, 1999, 09:07 PM
I need a file viewer.
Following is partial code.
Everything is ok if the file is NOT too big.
If a file is big such as one of my test case, length = 185191, the TextArea is empty.

This is happening on win95. No problem in winnt.
I feel this is a JAVA bug.(?) But I need a work around.

Please help. Thanks you very much.


===============================================
File f = new File(file_name);
BufferedReader br =
new BufferedReader(new FileReader(f));

long size = f.length();
System.out.println( " f.length=" + size );
int sz = (int) size;
char[] cbuf = new char[sz];
int n = br.read( cbuf, 0, sz );
TextArea ta= new TextArea( new String(cbuf), 24, 20);
......

Anna Chou

poochi
September 23rd, 1999, 11:18 PM
String cant hold more than 64K. So , create a char array that is less than 64K and
append it in the TextArea.

Anna Chou
September 24th, 1999, 03:30 AM
Thank you very much.
I tried what you suggested. Only append 64k at a time to the TextArea. But it did not work.
The problems I think are in the TextArea display.
I have checked the length of the text in the TextArea at the end. It equals to the file length which just read in. I still got a blank display in the case of file length > 64k.

Any more suggestions for work around?
( Same code works find in winnt )



Anna Chou