Question: File Decryption Filter Write a program that decrypts the file produced by the program in Programming Challenge 7. The decryption program should read the contents

File Decryption Filter Write a program that decrypts the file produced by the program in Programming Challenge 7. The decryption program should read the contents of the coded file, restore the data to its original state, and write it to another file. (Java) Did I do this right?

encryption.java

mport java.io.*; public class encryption { public static void main(String args[]) throws IOException { encrypt(new File("test.txt"), new File("test2.txt")); decrypt(new File("test2.txt"), new File("test.txt")); } public static void encrypt(File input, File output) throws IOException { DataInputStream in = new DataInputStream(new FileInputStream(input)); DataOutputStream out = new DataOutputStream(new FileOutputStream(output)); char c; try { while((c=in.readChar())!=0) { out.writeChar((char)(c+10)); } } catch(Exception ex) { } in.close(); out.close(); } public static void decrypt(File input, File output) throws IOException { DataInputStream in = new DataInputStream(new FileInputStream(input)); DataOutputStream out = new DataOutputStream(new FileOutputStream(output)); char c; try { while((c=in.readChar())!=0) { out.writeChar((char)(c-10)); } } catch(Exception ex) { } in.close(); out.close(); } }

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!