/**
* 将文件转成base64 字符串
*
* @param path 文件路径
* @return *
* @throws Exception
*/
public static String encodeBase64File(String path) {
File file = new File(path);
FileInputStream inputFile = null;
try {
inputFile = new FileInputStream(file);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
byte[] buffer = new byte[(int) file.length()];
try {
inputFile.read(buffer);
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
if (inputFile != null) {
inputFile.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
return new BASE64Encoder().encode(buffer);
}