blob: 03e575c4de9e515a53a9db5f078d42adf248395c (
plain)
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
|
package com.jantuomi.tunkki.utils;
import jline.console.ConsoleReader;
import java.io.IOException;
import java.io.PrintWriter;
/**
* Created by jan on 4.8.2016.
*/
public class IO {
private static IO instance = new IO();
private ConsoleReader reader;
private PrintWriter printer;
public static IO getInstance() {
return instance;
}
private IO() {
try {
reader = new ConsoleReader();
printer = new PrintWriter(System.out);
} catch (IOException e) {
e.printStackTrace();
}
reader.setBellEnabled(false);
reader.setExpandEvents(false);
}
public String readLine(String promptMessage)
throws IOException {
System.out.print(promptMessage);
String line = reader.readLine();
return line.trim();
}
public void printLine(String line) {
printer.println(line);
}
public void flush() {
printer.flush();
}
}
|