Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
package tcpipattacker;
 
import java.io.*;
 
/**
 * <p>Titre : TCPIP Attacker</p>
 * <p>Description : console to display TCPIPAttacker informations.
 * Also provide an interface between user inputs and ouputs </p>
 
 */
 
public class Console {
  protected static PrintStream output = new PrintStream(System.out);
  protected static BufferedReader input = new BufferedReader(new InputStreamReader(
      System.in));
  protected final static String PROMPT_STRING = "> ";
  protected String additionalPrompt = "";
 
  // Default constructor
  public Console() {
 
  }
 
  public Console(String prompt)
  {
    this.additionalPrompt = prompt;
  }
 
  public void println(String msg) {
    output.println(msg);
  }
 
  public void print(String msg) {
    output.print(msg);
  }
 
  public String prompt() {
    try {
      output.print(additionalPrompt + PROMPT_STRING);
      return input.readLine();
    }
    catch (IOException e) {
      return null;
    }
  }
 
  public String[] promptArray() { return prompt().split(" "); }
  public int promptInt() { String tmp = prompt(); return Integer.parseInt(tmp == "" ? "0" : tmp); }
  public long promptLong() { String tmp = prompt(); return Long.parseLong(tmp == "" ? "0" : tmp); }
}