Win a copy of Functional Design and Architecture this week in the Functional programming forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

binary and text data

 
Ranch Hand
Posts: 237
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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()
 
Ranch Hand
Posts: 276
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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!
 
anarkali perera
Ranch Hand
Posts: 237
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
sorry.
response.getPrintWriter() should be change as response.getWriter()
 
Lorand Komaromi
Ranch Hand
Posts: 276
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 237
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 276
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 237
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
can't i use response.getOutputStream() for writing text data?
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
 
Ranch Hand
Posts: 1325
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
you can use response.getOutput Writer() for writing text data.
 
anarkali perera
Ranch Hand
Posts: 237
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
can't i use response.get Writer (Writer.OUTPUT_BINARY) for writing text datda?
 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 237
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
can you give me a example for how to use getOutPutStream() for both text and binary ?
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic