我有这段代码可以使用 ical4j 从 ics 文件中导入日历:
CalendarBuilder calendarBuilder = new CalendarBuilder();
CompatibilityHints.setHintEnabled(CompatibilityHints.KEY_RELAXED_UNFOLDING, true);
net.fortuna.ical4j.model.Calendar iCalendar;
try {
iCalendar = calendarBuilder.build(icalInputStream);
} catch (ParserException e) {
if (logger.isDebugEnabled()) {
logger.debug("ParserException occurs when building iCalendar object", e);
}
throw new ParserException("Cannot parsed the input stream to iCalendar object", e.getLineNo());
}
代码总是抛出 ParserException。我发现如果我从这行 ics 文件中删除 X-RESPONSE-COMMENT,则代码通过:
ATTENDEE;CUTYPE=INDIVIDUAL;ROLE=REQ-PARTICIPANT;PARTSTAT=TENTATIVE;CN=abc
def;X-NUM-GUESTS=0;X-RESPONSE-COMMENT="JUGSummerCamp.
Si j'arrive à trouver un coin tranquille, je viendrais.":mailto:
abc@gmail.com
所以也许问题来自 X-RESPONSE-COMMENT。任何人都可以帮忙吗?谢谢。
更新: 确切的例外是:
Caused by: java.net.URISyntaxException: Illegal character in path at index 2: Si j'arrive à trouver un coin tranquille, je viendrais.":mailto:slemeur@exoplatform.com
at java.net.URI$Parser.fail(URI.java:2810)
at java.net.URI$Parser.checkChars(URI.java:2983)
at java.net.URI$Parser.parseHierarchical(URI.java:3067)
at java.net.URI$Parser.parse(URI.java:3025)
at java.net.URI.<init>(URI.java:577)
at net.fortuna.ical4j.util.Uris.create(Uris.java:108)
at net.fortuna.ical4j.model.property.Attendee.setValue(Attendee.java:108)
at net.fortuna.ical4j.data.CalendarBuilder.propertyValue(CalendarBuilder.java:294)
at net.fortuna.ical4j.data.CalendarParserImpl.parseProperty(CalendarParserImpl.java:236)
at net.fortuna.ical4j.data.CalendarParserImpl.parsePropertyList(CalendarParserImpl.java:167)
at net.fortuna.ical4j.data.CalendarParserImpl.parseComponent(CalendarParserImpl.java:334)
at net.fortuna.ical4j.data.CalendarParserImpl.parsePropertyList(CalendarParserImpl.java:164)
at net.fortuna.ical4j.data.CalendarParserImpl.parse(CalendarParserImpl.java:107)
... 31 more
包含非法字符的行是 ATTENDEE 属性的最后一行。谢谢。