File tree Expand file tree Collapse file tree 2 files changed +39
-1
lines changed
Expand file tree Collapse file tree 2 files changed +39
-1
lines changed Original file line number Diff line number Diff line change 11package base ;
2+ import java .io .FileNotFoundException ;
3+ import java .io .PrintWriter ;
24import java .util .Scanner ;
35
46public class Main {
57
68
7- public static void main (String [] args ) {
9+ public static void main (String [] args ) throws FileNotFoundException {
810
911 //Start the object e for AlphaNum encryptions
1012 Encrypt e = new Encrypt ();
@@ -51,6 +53,13 @@ public static void main(String[] args) {
5153 System .out .println ("Below is encrypted Text with Ceaser Cypher, offset of " + numEi );
5254 System .out .println (encrypted );
5355
56+ //Code to save file to EncryptedT.txt
57+ createfile c = new createfile ();
58+ c .openFile ();
59+ c .addRecords (encrypted );
60+ c .closeFile ();
61+ System .out .println ("The encrypted text was saved on EncryptedT.txt" );
62+
5463 System .out .println ("please reload the application again if you want to do another calculation" );
5564
5665 // close the scanner
Original file line number Diff line number Diff line change 1+ package base ;
2+
3+ import java .io .*;
4+ import java .lang .*;
5+ import java .util .*;
6+
7+ public class createfile {
8+
9+ private Formatter x ;
10+
11+ public void openFile () {
12+ try {
13+ x = new Formatter ("textE.txt" );
14+ } catch (Exception e ) {
15+ System .out .println ("Error with writting to file" );
16+ }
17+ }
18+ public void addRecords (String en ) {
19+ x .format ("%s" , en );
20+
21+ }
22+
23+ public void closeFile () {
24+ x .close ();
25+ }
26+
27+ }
28+
29+
You can’t perform that action at this time.
0 commit comments