File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes binary and text data Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "binary and text data" Watch "binary and text data" New topic
Author

binary and text data

anarkali perera
Ranch Hand

Joined: Sep 10, 2009
Posts: 237
1)if i neeed text data can i use both response.getOutputStream() and response.getPrintWriter()

2)1)if i neeed binarydata can i use both response.getOutputStream() and response.getPrintWriter()
Lorand Komaromi
Ranch Hand

Joined: Oct 08, 2009
Posts: 276
anarkali perera wrote:1)if i neeed text data can i use both response.getOutputStream() and response.getPrintWriter()

2)1)if i neeed binarydata can i use both response.getOutputStream() and response.getPrintWriter()


No, you can't, you'll need a Reader or InputStream!


OCJP 6 (93%)
anarkali perera
Ranch Hand

Joined: Sep 10, 2009
Posts: 237
sorry.
response.getPrintWriter() should be change as response.getWriter()
Lorand Komaromi
Ranch Hand

Joined: Oct 08, 2009
Posts: 276
Where would you need binary/text data and what would you use the streams/writers for..? You'd like to send it to the client, or what? Please clarify your question!
anarkali perera
Ranch Hand

Joined: Sep 10, 2009
Posts: 237
My question is
1)can i use both response.getWriter() and response.getOutputStream() for writing text data?

2)can i use both response.getWriter() and response.getOutputStream() for writing binary data?

Lorand Komaromi
Ranch Hand

Joined: Oct 08, 2009
Posts: 276
You should use getOutputStream() for binary and getWriter() for text data, because the latter will take care of the character encoding/MIME type of the response!
anarkali perera
Ranch Hand

Joined: Sep 10, 2009
Posts: 237
can't i use response.getOutputStream() for writing text data?
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12761
    
    5
2)can i use both response.getWriter() and response.getOutputStream() for writing binary data?


NO - of course not. Writers attempt to put character data into a specific encoding. With binary input such as image data you get gibberish output.

Bill
sam liyanage
Ranch Hand

Joined: Nov 25, 2008
Posts: 1072
you can use response.getOutput Writer() for writing text data.
anarkali perera
Ranch Hand

Joined: Sep 10, 2009
Posts: 237
can't i use response.get Writer (Writer.OUTPUT_BINARY) for writing text datda?
Praneeth Thiruveedhula
Greenhorn

Joined: Oct 20, 2009
Posts: 19
1)getOutPutStream(); is for both text and binary

2)getWriter(); is only for text data.

based on your requirement you can use it.
anarkali perera
Ranch Hand

Joined: Sep 10, 2009
Posts: 237
can you give me a example for how to use getOutPutStream() for both text and binary ?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: binary and text data
 
Similar Threads
Rare these two same
Get names of any one field in a database as radio button
Interview question I faced today!
Mobile App for Android and iPhone
About session