need a better way of displaying a text file in a jscrollpane

hello

i have a signed applet which reads a very large text file (25mb) from a urlConnection and copies all the text into a file local on the users machine. dont worry about security issues. this is an internal thing for work.

this part is fine. takes only a couple of seconds.

the problem is when i am opening this local file and attempting to output the contents line by line to a scrollable window. it works, but it takes ages. there are about 250,000 lines in the text file and it takes in the region of 15+ minutes!

here is the snippet of my code which is outputting to a scrollable window :

File f =new File("C:\\test_copy.txt");

BufferedReader br;

FileReader fr;

String line;

fr =new FileReader(f);

br =new BufferedReader(fr);

JTextArea data =new JTextArea("", 20,150);

data.setFont(new Font("Courier", Font.PLAIN, 10));

data.setEditable(false);

while ((line = br.readLine()) !=null){

System.out.println(line);

data.append(line);

}

JScrollPane dataWindow =new JScrollPane(data);

this.add(dataWindow);

System.out.println("complete");

is there a more efficient way i can achieve what im trying to do? if so, could anyone point me the correct way to do so?

thanks in advance.

[1777 byte] By [bsojitraa] at [2007-10-3 5:24:48]
# 1

try replacing this

while ((line = br.readLine()) != null) {

System.out.println(line);

data.append(line);

}

with

data.read(f,null);

Michael_Dunna at 2007-7-14 23:31:57 > top of Java-index,Java Essentials,New To Java...
# 2

> try replacing this

> > while ((line = br.readLine()) != null) {

> System.out.println(line);

> data.append(line);

> }

>

>

> with

> data.read(f,null);

did you mean

data.read(br,null);

i get an out of memory error.

im going to play around with creating a randomaccessfile with the local file and seek to only the lines needed as the user scrolls.

bsojitraa at 2007-7-14 23:31:57 > top of Java-index,Java Essentials,New To Java...