This week's book giveaway is in the Design forum.
We're giving away four copies of Building Microservices and have Sam Newman on-line!
See this thread for details.
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes What does Writing Binary Data Means? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Building Microservices this week in the Design forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "What does Writing Binary Data Means?" Watch "What does Writing Binary Data Means?" New topic

What does Writing Binary Data Means?

Alec Lee
Ranch Hand

Joined: Jan 28, 2004
Posts: 569
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

Joined: Aug 02, 2005
Posts: 27
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

Joined: Jan 28, 2004
Posts: 569
A TK question which means ..... we could face it in real life
Rizwan Mohammad
Ranch Hand

Joined: Sep 02, 2005
Posts: 445
what is TK question?

Have you checked out Aspose?
subject: What does Writing Binary Data Means?
It's not a secret anymore!