View Javadoc
1   package emissary.command;
2   
3   import java.io.BufferedReader;
4   import java.io.IOException;
5   import java.io.InputStream;
6   import java.io.InputStreamReader;
7   
8   public class Banner {
9   
10      static final String DEFAULT_TEXT = " ________  ________ _____ _____  ___  ________   __\n"
11              + "|  ___|  \\/  |_   _/  ___/  ___|/ _ \\ | ___ \\ \\ / /\n" + "| |__ | .  . | | | \\ `--.\\ `--./ /_\\ \\| |_/ /\\ V / \n"
12              + "|  __|| |\\/| | | |  `--. \\`--. \\  _  ||    /  \\ /  \n" + "| |___| |  | |_| |_/\\__/ /\\__/ / | | || |\\ \\  | |  \n"
13              + "\\____/\\_|  |_/\\___/\\____/\\____/\\_| |_/\\_| \\_| \\_/  \n";
14  
15      private final String bannerText;
16  
17      public Banner() {
18          InputStream in = this.getClass().getClassLoader().getResourceAsStream("banner.txt");
19          if (in == null) {
20              bannerText = DEFAULT_TEXT;
21          } else {
22              String bText = DEFAULT_TEXT;
23              try {
24                  BufferedReader reader = new BufferedReader(new InputStreamReader(in));
25                  StringBuilder result = new StringBuilder();
26                  String line;
27                  while ((line = reader.readLine()) != null) {
28                      result.append(System.getProperty("line.separator")).append(line);
29                  }
30                  bText = System.getProperty("line.separator") + result.toString();
31              } catch (IOException e) {
32                  // will be DEFAULT_TEXT;
33              }
34              bannerText = bText;
35          }
36      }
37  
38      @SuppressWarnings("SystemOut")
39      public void dump() {
40          System.out.println(bannerText);
41      }
42  }