抽取文件读取输出
public static void main(String[] args) throws IOException {
String docUploadPath = "D:\\mscordbi.dll";
File refereeFile = new File(docUploadPath);
byte[] refereeFileOriginalBytes = FileUtils.readFileToByteArray(refereeFile);
byte[] refereeFileBase64Bytes = Base64.encodeBase64(refereeFileOriginalBytes);
String UpFile = new String(refereeFileBase64Bytes, "UTF-8");
System.out.println(UpFile);
String content = UpFile;
FileOutputStream fop = null;
File file;
try {
file=new File("D:/t1.txt");
fop = new FileOutputStream(file);
// if file doesnt exists, then create it
if (!file.exists()) {
file.createNewFile();
}
// get the content in bytes
byte[] contentInBytes = content.getBytes();
fop.write(contentInBytes);
fop.flush();
fop.close();
System.out.println("Done");
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
if (fop != null) {
fop.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
}