-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTerminal.java
More file actions
63 lines (56 loc) · 1.68 KB
/
Copy pathTerminal.java
File metadata and controls
63 lines (56 loc) · 1.68 KB
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
51
52
53
54
55
56
57
58
59
60
61
62
63
package edu.kit.informatik;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
/**
* This class provides some simple methods for input/output from and to a terminal.
*
* Never modify this class, never upload it to Praktomat. This is only for your local use. If an assignment tells you to
* use this class for input and output never use System.out or System.in in the same assignment.
*
* @author ITI, VeriAlg Group
* @author IPD, SDQ Group
* @version 4
*/
public final class Terminal {
/**
* BufferedReader for reading from standard input line-by-line.
*/
private static BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
/**
* Private constructor to avoid object generation.
*/
private Terminal() {
}
/**
* Print a String to the standard output.
*
* The String out must not be null.
*
* @param out
* The string to be printed.
*/
public static void printLine(String out) {
System.out.println(out);
}
/**
* Reads a line from standard input.
*
* Returns null at the end of the standard input.
*
* Use Ctrl+D to indicate the end of the standard input.
*
* @return The next line from the standard input or null.
*/
public static String readLine() {
try {
return in.readLine();
} catch (IOException e) {
/*
* rethrow unchecked (!) exception to prevent students from being forced to use Exceptions before they have
* been introduced in the lecture.
*/
throw new RuntimeException(e);
}
}
}