base64.求助。。
public static String getWord(String filePath) {
String result = null;
File file = new File(filePath);
try {
FileInputStream fis = new FileInputStream(file);
WordExtractor wordExtractor = new WordExtractor(fis);
result = wordExtractor.getText();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
;
return result;
}
我想把读取的word文档读取成base64加密过的,请问如何修改此方法?
------解决方案--------------------public static String getWord(String filePath) {
String result = null;
File file = new File(filePath);
try {
FileInputStream fis = new FileInputStream(file);
WordExtractor wordExtractor = new WordExtractor(fis);
result = wordExtractor.getText();
/*base64加密*/
System.out.println(new BASE64Encoder()).encodeBuffer(result));
} catch (File
NotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
;
return result;
}