File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
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?

I agree. Here's the link:
subject: What does Writing Binary Data Means?
It's not a secret anymore!