JavaIO model - the decorator pattern

JavaIO reflect the Decorator design pattern

Today before school SparkRDD, he listened to a review JavaIO of course, that she spoke well

Java's IO has made me feel very troublesome layer by layer, the fourth year when the reason is not clear

To know the decomposition of the input and output streams and process stream; byte character stream;

By following this example, the decomposition of the Decorator Pattern, is a step by step how decorative

InputStream in = new FileInputStream("xxxxxxxx")
Reader reader = new BufferReader(new InputStreamReader( in , "UTF-8"))

  • FileInputStream only responsible for reading character streams;
  • Further InputStreamReader decorated increase of UTF-8 encoding
  • Buffer BufferedReader by the read contents stored, disposable, each line output to the user;

Guess you like

Origin www.cnblogs.com/mussessein/p/11615706.html