package com.cjavapy.utils.util;
import sun.misc.BASE64Decoder;
import sun.misc.BASE64Encoder;
import java.io.*;
public class Base64Convert {
private void Base64Convert() {
}
public static String ioToBase64(InputStream in) throws IOException {
String strBase64 = null;
try {
byte[] bytes = new byte[in.available()];
in.read(bytes);
strBase64 = new BASE64Encoder().encode(bytes);
} finally {
if (in != null) {
in.close();
}
}
return strBase64;
}
public static String byteToBase64(byte[] bytes) {
String strBase64 = null;
strBase64 = new BASE64Encoder().encode(bytes);
return strBase64;
}
public static byte[] base64ToByte(String strBase64) throws IOException {
byte[] bytes = new BASE64Decoder().decodeBuffer(strBase64);
return bytes;
}
}