Here you can find the source of base64FromBinary(byte[] value)
Parameter | Description |
---|---|
value | A binary value. |
Parameter | Description |
---|---|
IllegalArgumentException | If the given value is null. |
public static String base64FromBinary(byte[] value) throws IllegalArgumentException
//package com.java2s; /*// ww w . ja v a2s.co m * Copyright (C) 2014 Dell, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import java.util.Arrays; import javax.xml.bind.DatatypeConverter; public class Main { /** * Convert (encode) the given binary value using Base64. * * @param value A binary value. * @return Base64-encoded value. * @throws IllegalArgumentException If the given value is null. */ public static String base64FromBinary(byte[] value) throws IllegalArgumentException { return DatatypeConverter.printBase64Binary(value); } /** * Convert (encode) the given binary value, beginning at the given offset and * consisting of the given length, using Base64. * * @param value A binary value. * @param offset Zero-based index where data begins. * @param length Number of bytes to encode. * @return Base64-encoded value. * @throws IllegalArgumentException If the given value is null. */ public static String base64FromBinary(byte[] value, int offset, int length) throws IllegalArgumentException { return DatatypeConverter.printBase64Binary(Arrays.copyOfRange(value, offset, offset + length)); } }