1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 package gnu.inet.ftp;
22
23 public class ServerResponseException extends Exception {
24 private long code;
25 private String message;
26
27 /***
28 * basic constructor. creates a new ServerResponseException given the server
29 * error message. The input string must be in the format of 3 digits, a
30 * space and the error message. This is the default format of the server
31 * responses.
32 *
33 * @param str
34 * the server error message in the form
35 */
36 public ServerResponseException(java.lang.String str) {
37 code = -1;
38 message = str;
39 }
40
41 /***
42 * get the server response code.
43 *
44 * @exception NumberFormatException
45 * the first 3 characters of the message are <i>not</i>
46 * a number as they should be in a normal server response
47 * @return server response code as long value
48 */
49 public long getCode() throws NumberFormatException {
50 code = Integer.parseInt(message.substring(0, 3));
51 return code;
52 }
53
54 /***
55 * get the server message.
56 *
57 * @return the full server response message string
58 */
59 public String getMessage() {
60 return message;
61 }
62
63 /***
64 * get a string representing this ServerResponseException
65 *
66 * @return this ServerResponseException as a String
67 */
68 public String toString() {
69 return message;
70 }
71
72 }
73
74