看下思路就行了,实际还有bug
public static void getPlace() throws IOException {
Set<String> placeList=new LinkedHashSet<>();
XWPFDocument doc = new XWPFDocument(
new FileInputStream("src")
);
List<XWPFTable> ta=doc.getTables();
System.out.println("---------------------");
ta.forEach(i->{
i.getRows().forEach(r->{
r.getTableCells().forEach(cell->{
placeList.add(cell.getText());
});
});
});
System.out.println("----");
List<XWPFParagraph>pg= doc.getParagraphs();
pg.forEach(e->{
String temp=e.getText();
int start=0;
int end=0;
int sign=0;
for (int index=0;index<temp.length();index++){
switch (temp.charAt(index)){
case '$':{
if((index+1!=temp.length())&&temp.charAt(index+1)=='{')
{start=index;sign=1;}
break;
}
case '}':{
if (sign==1){
end=index;
placeList.add(temp.substring(start,end+1));
sign=0;
}
}
}
}
});
System.out.println(placeList);
placeList.forEach(s -> {
System.out.println("params.put(\""+s+"\",\"----\");");
});
}