• Post Reply Bookmark Topic Watch Topic
  • New Topic

Using ServletOutputStream to write contents to a download file

 
suresh peter
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello

I am using ServletOutputStream and wrapping it with PrintStream (and tried PrintWriter) to write contents to a RTF file that the user downloads. The input for PrintStream is a String text obtained from a database layer. It contains special characters. I am able to create and download the file successfully, but the special characters are not being displayed correctly.

/*
response.setContentType("application/rtf");
response.setHeader("Content-disposition","file; filename=sample.rtf"); //RTF file being downloaded

ServletOutputStream stream = response.getOutputStream();
PrintStream out = new PrintStream(stream,true,"UTF-8");
out.println("Dear Dr. AuthorŖ: Thank you for"); //Notice the special character in the string
out.flush();
stream.close();

*/

Please suggest how i could handle this issue.

Thanks
Suresh
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!