-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathJavaCompiler.java
More file actions
32 lines (26 loc) · 935 Bytes
/
JavaCompiler.java
File metadata and controls
32 lines (26 loc) · 935 Bytes
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
package regexmatch;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
public class JavaCompiler {
public static void main(String[] args) throws FileNotFoundException, UnsupportedEncodingException, IOException {
Scanner sc = new Scanner(new FileReader("input.txt"));
//reads the file "input.txt"
PrintWriter writer = new PrintWriter("Test.java", "UTF-8");
while (sc.hasNext()) {
String str = sc.nextLine();
//replaces kung with if
str = str.replaceAll("kung", "if");
str = str.replaceAll("labas", "out");
str = str.replaceAll("iprint", "println");
writer.println(str);
}
writer.close();
}
}