KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > ws > jaxme > util > Base64Binary


1 /*
2  * Copyright 2003, 2004 The Apache Software Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15
16  */

17 package org.apache.ws.jaxme.util;
18
19 import java.io.IOException JavaDoc;
20
21 import sun.misc.BASE64Decoder;
22 import sun.misc.BASE64Encoder;
23
24
25 /** A utility class for working with base64 encoding.
26  */

27 public class Base64Binary {
28     /** Creates a clone of the byte array <code>pValue</code>.
29      */

30     public static byte[] getClone(byte[] pValue) {
31         byte[] result = new byte[pValue.length];
32         System.arraycopy(pValue, 0, result, 0, pValue.length);
33         return result;
34     }
35
36     /** Converts the string <code>pValue</code> into a
37      * base64 encoded byte array.
38      */

39     public static byte[] decode(String JavaDoc pValue) throws IOException JavaDoc {
40         return (new BASE64Decoder()).decodeBuffer(pValue);
41     }
42
43     /** Converts the base64 encoded byte array <code>pValue</code>
44      * into a string.
45      */

46     public static String JavaDoc encode(byte[] pValue) {
47         return (new BASE64Encoder()).encode(pValue);
48     }
49 }
50
Popular Tags