64位编码
public String getFileBase64(String filePath) throws IOException {
String base64Code = null;
InputStream in = null;
byte[] data = null;
try{
in = new FileInputStream(filePath);
data = new byte[in.available()];
in.read(data);
}catch (IOException e) {
e.printStackTrace();
}finally {
if(in != null) {
in.close();
}
}
//对字节base64编码
String tempstr = null;
byte[] base64Data = Base64.encodeBase64(data, true);
if(base64Data!=null){
tempstr = new String(base64Data);
}
return tempstr;
}