-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathex.java
50 lines (37 loc) · 1.04 KB
/
ex.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Scanner;
public class ex {
public static void main(String[] args) throws Exception{
String s = "This is the first encryption code for me.";
enc(s);
dec("pr.txt");
}
public static void enc(String str) throws IOException{
PrintWriter pr = new PrintWriter("pr.txt");
String st = "";
char[] cha = str.toCharArray();
for(char c:cha){
int i = c + 10;
st += ((char)i);
}
System.out.println(st);
pr.print(st);
pr.close();
}
public static void dec(String name) throws IOException{
File f = new File(name);
Scanner s = new Scanner(f);
String re = "";
while (s.hasNext()){
String st = s.nextLine();
char[] ch = st.toCharArray();
for(char c:ch){
int i = c - 10;
re += (char)i;
}
}
System.out.println(re);
}
}