dcsimg
How to read A large XML file in an Applet in the fastest way possible.
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   harshat_Taide
Posted On:   Thursday, July 11, 2002 01:54 PM

Hi, I have an applet that needs to read a large XML file (257 kb) that will be on the same host as the applet. I have been told that I cannot read the FileReader with an applet. And I do not want to get my applet signed. So I have written a method in my applet that reads a file. I call this method and pass the file name (rules.xml) in the path variable of the method GetTextFile. private String GetTextFile(String path, URL codebase) { String result = ""; try { URL url = new URL(codebase, path); InputStream is = url.openStream(); BufferedReader aFile = new BufferedReader(new Input   More>>

Hi,

I have an applet that needs to read a large XML file (257 kb) that will be on the same host as the applet. I have
been told that I cannot read the FileReader with an applet. And I do not want to get my applet signed.



So I have written a method in my applet that reads a file.
I call this method and pass the file name (rules.xml) in
the path variable of the method GetTextFile.




private String GetTextFile(String path, URL codebase)

{

String result = "";

try

{

URL url = new URL(codebase, path);

InputStream is = url.openStream();

BufferedReader aFile = new BufferedReader(new InputStreamReader(is));

String s;



while ((s = aFile.readLine()) != null)


{

result = result + s;

}

aFile.close();

is.close();



}

catch(..){..}

return result;

}





I am able to read the file and everything works fine but the only problem is it takes a lot of time to read the file
even though I am using the bufferedReader.




Earlier I was not using a Buffered Reader and it was mighty slow. And using Buffered Reader has improved the performance.


I read somewhere that you can create ur own buffer. But I tried doing it and it prints some junk. Possibly because my
data file is character based and not binary data.

Is there any way to make it more faster. Any help is appreciated. If you could help with an example, I would be grateful.


Thanks,
Harsha

   <<Less
About | Sitemap | Contact