Created
February 8, 2021 16:57
-
-
Save anjanashankar9/576a894f117518d9866675d1caa51b67 to your computer and use it in GitHub Desktop.
java-decorator-pattern
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void main() { | |
// FileInputStream - responsible for reading the file | |
FileInputStream fileInputStream = new FileInputStream("file.txt"); | |
// BufferedInputStream extends FilterInputStream and not FileInputStream, it is | |
// a decorator which enhances the functionality of the original object by wrapping over it. | |
BufferedInputStream bufferedInputStream = new BufferedInputStream(fileInputStream); | |
// The read operation becomes buffered now | |
bufferedInputStream.read(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment