1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 package net.sourceforge.servletspy;
22
23 import java.io.BufferedReader;
24 import java.io.IOException;
25 import java.io.InputStream;
26 import java.io.InputStreamReader;
27 import java.io.PrintWriter;
28 import java.io.Serializable;
29 import java.io.StringWriter;
30
31 /***
32 * @author arno schumacher
33 */
34 public final class About implements Serializable {
35
36 /*** The serial version id. */
37 private static final long serialVersionUID = -2036186781095617094L;
38
39 /*** The location of the license file. */
40 private static final String RESOURCE = "META-INF/SERVLETSPY-LICENSE.txt";
41
42 /*** String holding the license. */
43 private String license = "GNU GENERAL PUBLIC license, Version 2, June 1991";
44
45 /***
46 * Constructor.
47 */
48 public About() {
49 final StringWriter stringWriter = new StringWriter();
50 final PrintWriter writer = new PrintWriter(stringWriter);
51 try {
52 final InputStream ios = Thread.currentThread()
53 .getContextClassLoader().getResourceAsStream(RESOURCE);
54 if (ios == null) {
55 throw new IOException("Resource '" + RESOURCE
56 + "' could not be found.");
57 }
58 final BufferedReader in = new BufferedReader(new InputStreamReader(
59 ios));
60 String s = in.readLine();
61 while (s != null) {
62 writer.println(s);
63 s = in.readLine();
64 }
65 in.close();
66 stringWriter.close();
67 license = stringWriter.toString();
68 } catch (Exception e) {
69 e.printStackTrace();
70 }
71 }
72
73 /***
74 * Returns the license information.
75 *
76 * @return String providing the license information.
77 */
78 public String getLicense() {
79 return license;
80 }
81 }