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

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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!