Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Java streaming big string  RSS feed

 
Joe Stela
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I have a very big string that I am returning from servlet to javascript. I am using PrintWriter.

PrintWriter out = response.getWriter();
out.print(bigString);

But as the string is very big my code is not working. My browser just hangs.

Is there any way I can fix this.

Also is it possible to stream the output? i.e instead of sending entire string, can I send small part of string at a time. So that my browser will not hang.
I don't want to handle streaming manually I am just looking for an IO class which will do the streaming automatically.

Thanks.
 
Alice Hampton
Ranch Hand
Posts: 217
Chrome Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Could you not use split string at all to split it up into sections?
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!