-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHackerTyper.java
More file actions
44 lines (36 loc) · 915 Bytes
/
HackerTyper.java
File metadata and controls
44 lines (36 loc) · 915 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
33
34
35
36
37
38
39
40
41
42
43
44
import java.nio.file.Files;
import java.nio.file.Paths;
import java.io.IOException;
public class HackerTyper {
private String code;
public HackerTyper() {
code = getCode();
}
private String getCode() {
try {
code = new String(Files.readAllBytes(Paths.get("./code.txt")));
return code;
} catch (IOException ex) {
System.err.println("Could not read code.txt.");
throw new RuntimeException(ex);
}
}
public void type() {
printDelayed(code);
}
private void printDelayed(String code) {
try {
for (int i = 0; i < code.length(); i++) {
System.out.print(code.charAt(i));
Thread.sleep(200);
}
} catch (InterruptedException ex) {
System.err.println("Error while tried to print delayed.");
throw new RuntimeException(ex);
}
}
public static void main(String[] args) throws Exception {
HackerTyper hackerTyper = new HackerTyper();
hackerTyper.type();
}
}