- Code: Select all
public class loadAndSaveToDisk {
// public static void main(String[] args) {
public void SaveBase64ToDisk(String base64FileData) throws IOException {
System.out.println("base64文件编码:"+base64FileData);
// Base64解码
BASE64Decoder decoder = new BASE64Decoder();
byte[] byteArr = decoder.decodeBuffer(base64FileData);
InputStream inputStream = new ByteArrayInputStream(byteArr);
System.out.println("保存Word到本地");
// String input = "data/Template.docx";
//Create a new document
Document doc = new Document();
// Load the document fromdoc the absolute/relative path on disk.
// doc.loadFromFile(input);
doc.loadFromStream(inputStream,FileFormat.Doc);
String result = "C:\\ecologyFileSave\\test\\test.doc";
// Save the document to disk
doc.saveToFile(result,FileFormat.Doc);
}
}