FAQ | This is a LIVE service | Changelog

Skip to content
Snippets Groups Projects
Commit d9036ef1 authored by Andrew Rice's avatar Andrew Rice
Browse files

commented patterns

parent 60f1a141
Branches master
No related tags found
No related merge requests found
......@@ -4,6 +4,7 @@ import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
......@@ -20,9 +21,11 @@ public class Readers {
// Demonstrate decorator and adaptor pattern
try (BufferedReader is =
new BufferedReader(
new InputStreamReader(
new GZIPInputStream(new FileInputStream(book)), StandardCharsets.UTF_8))) {
new BufferedReader( // decorator
new InputStreamReader( // adapter
new GZIPInputStream( // decorator
new FileInputStream(book) // concrete implementation
), StandardCharsets.UTF_8))) {
String line;
while ((line = is.readLine()) != null) {
System.out.println(line);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment