Well I'm having functions generate strings of between 2-3Mb no problems at
all (XML file for a 100-bus power network if you're wondering). Not sure
what the limits to the size of a String is, but so far, not met it.
Alan
On 8/12/04 4:02 pm, "Michael Rasmussen" <email@hidden> wrote:
> Using a string buffer may help you out. Also, I am not sure at all on
> this so I am asking what the maximum size for a string is, A 512 KB
> string seems big.
> Michael
>
>
> On Wed, 08 Dec 2004 15:38:33 +0000, Alan McMorran <email@hidden> wrote:
>> Since I seem to have gotten into the bad habit of replying to my own
>> emails...
>>
>>
>>
>>> 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());
>>> }
>>>
>>> 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.
>>
>> You can do:
>>
>> StringWriter stringOutput = new StringWriter();
>> PrintWriter printOutput = new PrintWriter(stringOutput);
>> For (int I=0; I<objects.length; I++){
>> printOutput.println(objects[I].outputXML());
>> }
>> printOutput.close();
>>
>> Return stringOutput.toString();
>>
>> And that should return a String and doesn't seem to have the bottlenecks you
>> get when doing += on a String object.
>>
>> Hope that helps.
>>
>> Alan
>>
>>
>>
>>
>> _______________________________________________
>> 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
>>
>
------ End of Forwarded Message
_______________________________________________
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