I had a similar problem with a command line utility that looped through
several thousand objects running an outputXML() function I wrote that
basically put the data into a standard XML format.
I had originally made it do:
String ret = new String();
For (int I=0; I<objects.length; I++){
ret += objects[I].outputXML() + "\n";
}
Return ret;
Then put the string into a file, but the time taken increased exponentially
as the number of objects increased. When I changed it to:
PrintWriter fileOutput = new PrintWriter(new FileWriter(new
File("outputFile"));
For (int I=0; I<objects.length; I++){
fileOutput.println(objects[I].outputXML());
}
It was far far quicker (from several minutes to a few seconds).
I know it's not an exact solution, and puts the output into a file rather
than to a variable, but that's because I'm using a FileWriter for my
implementation, and I'm sure there are other ways to use a PrintWriter
rather than outputting to a file that would solve your problem.
Hope that's of some help though.
Alan
P.S. Just noticed Entourage insists on capitalising various commands in the
above code, but you get the general idea.
On 8/12/04 3:14 pm, "Mohammad Ali Salahuddin" <email@hidden> wrote:
> Hello,
>
> I am using a signed applet (self-signed) to read files from a clients
> machine (local file system). Following is the code for buffered reading (the
> meat):
>
> String thisLine, ret = "";
> try{
> BufferedReader myInput = new BufferedReader(new FileReader(fn));
> while ((thisLine = myInput.readLine()) != null) {
> ret += thisLine + "\n";
> }
> myInput.close();
> }
> catch (Exception e) {
> ret = "Cannot load, exception!";
> }
>
> When I read a file <= 512KB, it runs fine/as expected. Now, when I read a
> file, say for example 1024KB in size, I expect the application to take twice
> as much time (than 512KB file) and read the file, but instead the
> applet/browser hangs. As a matter of fact I am not able to read files >
> 512KB.
>
> So, is there a limit on file size (from local file system) when reading from
> an applet, or is it to do with the way I am reading it?
>
> Any help, suggestions or comments would be highly appreciated.
>
> Thanks in advance.
>
>
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Java-dev mailing list (email@hidden)
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/java-dev/email@hidden
>
> This email sent to email@hidden
>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Java-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/java-dev/email@hidden
This email sent to email@hidden