Question: The Java class FileWriter is used for writing data to a file. It is desired to define a Java class for writing data to a
The Java class FileWriter is used for writing data to a file. It is desired to define a Java class for writing data to a file in an encrypted form. Show how to use the Decorator design pattern to define a class EncryptedFileWriter that stores an encryption key and whose write methods call an encrypt method to write an encrypted data to the decorated FileWriter. An example of the intended usage is as follows. FileWriter out new FileWriter( EncryptedFilewriter encryptout -new EncryptedFileWriter (out, key) int x encryptout.write (x) Hints &Tips: Make sure that your design actually conforms to the Decorator pattern
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
