Net-informations.com
SiteMap  | About    

OutPutStreamWriter Class

Java OutPutStreamWriter tutorial

The OutPutStreamWriter write characters to an output stream, translating characters into bytes according to a specified character encoding . Each OutputStreamWriter incorporates its own CharToByteConverter , and is thus a bridge from character streams to byte streams.

Characters written to it are encoded into bytes using a specified charset. The encoding used by an OutputStreamWriter may be specified by name, by providing a CharToByteConverter , or by accepting the default encoding, which is defined by the system property file.encoding . It has alternative constructors that allow you to specify the character set (ex: ISO-Latin1, UTF-8, UTF-16 etc.) to use to convert the written characters to the bytes written to the underlying OutputStream .

Example

When do you use a Reader/Writer and when a Stream?

When and where use a Reader/Writer or a Stream?
  1. If you are dealing non-ASCII Unicode characters, e.g. Chinese, use Readers/Writers.
  2. If you are handling with binary data (e.g. an image) use Streams.
  3. If you are dealing ordinary ASCII text (the traditional 0-127 characters) you can use either.









net-informations.com (C) 2017    Founded by raps mk
All Rights Reserved. All other trademarks are property of their respective owners.