发布网友 发布时间:2022-04-21 23:34
共1个回答
热心网友 时间:2023-05-18 06:29
楼主你可以这样操作,导入java.io.*。org.apache.poi.hwpf.*。org.apache.poi.hwpf.usermodel.Picture
String savePath= "c:\\temp\\";
String docFile= savePath+ "test.doc";
String imgFile= savePath+ "img.jpg";
HWPFDocument poiDoc = new HWPFDocument(new FileInputStream(docFile));
List picList=poiDoc.getPicturesTable().getAllPictures();
Picture picture=(Picture)picList.get(0);
try {
picture.writeImageContent(new FileOutputStream(imgFile));
} catch (FileNotFoundException e) {
e.printStackTrace();
}