亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

請問這么引入rtf文件為什么會報如下錯誤:

請問這么引入rtf文件為什么會報如下錯誤:

繁花如伊 2022-10-02 13:09:46
Document document = new Document(PageSize.A4);RtfWriter2 rtf = RtfWriter2.getInstance(document, new FileOutputStream("path"));document.open();BaseFont bfChinese = BaseFont.createFont("STSongStd-Light","UniGB-UCS2-H", BaseFont.NOT_EMBEDDED);rtf.importRtfDocument(new FileInputStream("oldPath"));document.add(new Paragraph("Hello World"));document.close();java.lang.NullPointerExceptionat com.lowagie.text.rtf.parser.destinations.RtfDestinationFontTable.importSystemFonts(Unknown Source)at com.lowagie.text.rtf.parser.destinations.RtfDestinationFontTable.init(Unknown Source)at com.lowagie.text.rtf.parser.destinations.RtfDestinationFontTable.setParser(Unknown Source)at com.lowagie.text.rtf.parser.destinations.RtfDestinationMgr.addDestination(Unknown Source)at com.lowagie.text.rtf.parser.ctrlwords.RtfCtrlWordHandler.<init>(Unknown Source)at com.lowagie.text.rtf.parser.ctrlwords.RtfCtrlWordMap.<init>(Unknown Source)at com.lowagie.text.rtf.parser.ctrlwords.RtfCtrlWordMgr.<init>(Unknown Source)at com.lowagie.text.rtf.parser.RtfParser.init(Unknown Source)at com.lowagie.text.rtf.parser.RtfParser.importRtfDocument(Unknown Source)at com.lowagie.text.rtf.RtfWriter2.importRtfDocument(Unknown Source)at com.lowagie.text.rtf.RtfWriter2.importRtfDocument(Unknown Source)
查看完整描述

1 回答

?
猛跑小豬

TA貢獻1858條經驗 獲得超8個贊

因為它找font只支持到windows vista,你要補充個windows7或8的條件在源碼里,然后編譯打包替換。
private Properties getEnvironmentVariables() throws Throwable {
Properties environmentVariables = new Properties();
String operatingSystem = System.getProperty("os.name").toLowerCase();
Runtime runtime = Runtime.getRuntime();
Process process = null;
if (operatingSystem.indexOf("windows 95") > -1
|| operatingSystem.indexOf("windows 98") > -1
|| operatingSystem.indexOf("me") > -1) {
process = runtime.exec("command.com /c set");
} else if ((operatingSystem.indexOf("nt") > -1)
|| (operatingSystem.indexOf("windows 2000") > -1)
|| (operatingSystem.indexOf("windows xp") > -1)
|| (operatingSystem.indexOf("windows 2003") > -1)
|| (operatingSystem.indexOf("windows 7") > -1)
|| (operatingSystem.indexOf("windows vista") > -1)) {
process = runtime.exec("cmd.exe /c set");
} else {
process = runtime.exec("env");
}
BufferedReader environmentStream = new BufferedReader(new InputStreamReader(process.getInputStream()));
String inputLine = "";
int idx = -1;
while ((inputLine = environmentStream.readLine()) != null) {
idx = inputLine.indexOf('=');
environmentVariables.setProperty(inputLine.substring(0, idx),
inputLine.substring(idx + 1));
}
return environmentVariables;
}

查看完整回答
反對 回復 2022-10-06
  • 1 回答
  • 0 關注
  • 184 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號