public static void main(String[] args) throws IOException {
FileInputStream fs = new FileInputStream("E:\\ipr\\司机手册.doc");
HWPFDocument doc = new HWPFDocument(fs);
Range r = doc.getRange();
PicturesTable pTable = doc.getPicturesTable();
String docText = "";
for (int x = 0; x < r.numSections(); x++) {
Section s = r.getSection(x);
for (int y = 0; y < s.numParagraphs(); y++) {
Paragraph p = s.getParagraph(y);
for (int z = 0; z < p.numCharacterRuns(); z++) {
CharacterRun run = p.getCharacterRun(z);
if (pTable.hasPicture(run)) {
System.out.print("has pic\n");
docText+="*******************************************\r\n";
} else {
System.out.print("no pic\n");
} }
docText += p.text();
}
}
System.out.println(docText);
}CharacterRun 函数的作用是什么, p.numCharacterRuns()确良读取长度是什么的长度?我查了API但是还是不太清楚。
FileInputStream fs = new FileInputStream("E:\\ipr\\司机手册.doc");
HWPFDocument doc = new HWPFDocument(fs);
Range r = doc.getRange();
PicturesTable pTable = doc.getPicturesTable();
String docText = "";
for (int x = 0; x < r.numSections(); x++) {
Section s = r.getSection(x);
for (int y = 0; y < s.numParagraphs(); y++) {
Paragraph p = s.getParagraph(y);
for (int z = 0; z < p.numCharacterRuns(); z++) {
CharacterRun run = p.getCharacterRun(z);
if (pTable.hasPicture(run)) {
System.out.print("has pic\n");
docText+="*******************************************\r\n";
} else {
System.out.print("no pic\n");
} }
docText += p.text();
}
}
System.out.println(docText);
}CharacterRun 函数的作用是什么, p.numCharacterRuns()确良读取长度是什么的长度?我查了API但是还是不太清楚。
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货