我要抓住這個例外,我想在做這裏的catch塊一些treatement的代碼:測試的十六進制數值
try {
root.setText(page.getText(field.getLine() + repetition,
field.getColumn(),
field.getLength()));
} catch (org.jdom2.IllegalDataException e) {
// ignore: some lines can be empty and cannot
// be a valid XML character so we skip them
String invalidStr = page.getText(field.getLine() + repetition, field.getColumn(),field.getLength());
}
下面是當我使用e.printStackTrace印刷錯誤();方法:
org.jdom2.IllegalDataException: The data "
" is not legal for a JDOM character content: 0x000c is not a legal XML character.
at org.jdom2.Text.setText(Text.java:182)
因此如何使測試上的字符0x000c值:
String invalidStr = page.getText(field.getLine() + repetition, field.getColumn(),field.getLength());
if (invalidStr.equals(???)) {
}
預先感謝您
這是否對你的作品(invalidStr.indexOf(0x000C)? – Mani