1 |
| |
2 |
| |
3 |
| |
4 |
| |
5 |
| |
6 |
| |
7 |
| |
8 |
| |
9 |
| |
10 |
| |
11 |
| |
12 |
| |
13 |
| |
14 |
| |
15 |
| |
16 |
| |
17 |
| |
18 |
| package org.apache.geronimo.mail.util; |
19 |
| |
20 |
| import java.io.ByteArrayOutputStream; |
21 |
| import java.io.IOException; |
22 |
| import java.io.OutputStream; |
23 |
| |
24 |
| public class UUEncode { |
25 |
| private static final Encoder encoder = new UUEncoder(); |
26 |
| |
27 |
| |
28 |
| |
29 |
| |
30 |
| |
31 |
| |
32 |
0
| public static byte[] encode(
|
33 |
| byte[] data) |
34 |
| { |
35 |
0
| return encode(data, 0, data.length);
|
36 |
| } |
37 |
| |
38 |
| |
39 |
| |
40 |
| |
41 |
| |
42 |
| |
43 |
0
| public static byte[] encode(
|
44 |
| byte[] data, |
45 |
| int off, |
46 |
| int length) |
47 |
| { |
48 |
0
| ByteArrayOutputStream bOut = new ByteArrayOutputStream();
|
49 |
| |
50 |
0
| try
|
51 |
| { |
52 |
0
| encoder.encode(data, off, length, bOut);
|
53 |
| } |
54 |
| catch (IOException e) |
55 |
| { |
56 |
0
| throw new RuntimeException("exception encoding UUEncoded string: " + e);
|
57 |
| } |
58 |
| |
59 |
0
| return bOut.toByteArray();
|
60 |
| } |
61 |
| |
62 |
| |
63 |
| |
64 |
| |
65 |
| |
66 |
| |
67 |
0
| public static int encode(
|
68 |
| byte[] data, |
69 |
| OutputStream out) |
70 |
| throws IOException |
71 |
| { |
72 |
0
| return encoder.encode(data, 0, data.length, out);
|
73 |
| } |
74 |
| |
75 |
| |
76 |
| |
77 |
| |
78 |
| |
79 |
| |
80 |
0
| public static int encode(
|
81 |
| byte[] data, |
82 |
| int off, |
83 |
| int length, |
84 |
| OutputStream out) |
85 |
| throws IOException |
86 |
| { |
87 |
0
| return encoder.encode(data, 0, data.length, out);
|
88 |
| } |
89 |
| |
90 |
| |
91 |
| |
92 |
| |
93 |
| |
94 |
| |
95 |
0
| public static byte[] decode(
|
96 |
| byte[] data) |
97 |
| { |
98 |
0
| ByteArrayOutputStream bOut = new ByteArrayOutputStream();
|
99 |
| |
100 |
0
| try
|
101 |
| { |
102 |
0
| encoder.decode(data, 0, data.length, bOut);
|
103 |
| } |
104 |
| catch (IOException e) |
105 |
| { |
106 |
0
| throw new RuntimeException("exception decoding UUEncoded string: " + e);
|
107 |
| } |
108 |
| |
109 |
0
| return bOut.toByteArray();
|
110 |
| } |
111 |
| |
112 |
| |
113 |
| |
114 |
| |
115 |
| |
116 |
| |
117 |
0
| public static byte[] decode(
|
118 |
| String data) |
119 |
| { |
120 |
0
| ByteArrayOutputStream bOut = new ByteArrayOutputStream();
|
121 |
| |
122 |
0
| try
|
123 |
| { |
124 |
0
| encoder.decode(data, bOut);
|
125 |
| } |
126 |
| catch (IOException e) |
127 |
| { |
128 |
0
| throw new RuntimeException("exception decoding UUEncoded string: " + e);
|
129 |
| } |
130 |
| |
131 |
0
| return bOut.toByteArray();
|
132 |
| } |
133 |
| |
134 |
| |
135 |
| |
136 |
| |
137 |
| |
138 |
| |
139 |
0
| public static int decode(
|
140 |
| String data, |
141 |
| OutputStream out) |
142 |
| throws IOException |
143 |
| { |
144 |
0
| return encoder.decode(data, out);
|
145 |
| } |
146 |
| } |
147 |
| |