Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

What does Writing Binary Data Means?

 
Alec Lee
Ranch Hand
Posts: 569
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For a given Servlet Response response, which retrieves an object for writing binary data?
(Choose two)
A. response.getWriter ()
B. response.getOutputStream ()
C. response.getOutputWriter()
D. response.getWriter().getOutputStream()
E. response.getWriter(Writer.OUTPUT_BINARY)

A, B are the answers given. But how can PrintWriter used to write binary data? (my java io knowledge is a bit limited)

The write() method of PrintWriter does accept char[] or int - but not byte/byte[]. Does that mean we cannot send arbitrary bytes to the stream?
 
Alexandre Cervieri
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Alec, where did this question come from?
I don't understand how A and B could be right. Every book or web page I read about writing binary data from a servlet they emphasize that we should use the getOutputStream() and this should also be the answer for certification questions. Are you sure the answers are right? I mean, I was pretty sure about that, now I think that I know nothing about servlets
 
Alec Lee
Ranch Hand
Posts: 569
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A TK question which means ..... we could face it in real life
 
Rizwan Mohammad
Ranch Hand
Posts: 445
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what is TK question?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic