- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用 ical4j 来解析 Android 上的 ical 格式。
我的输入 ics 是:
BEGIN:VCALENDAR
BEGIN:VEVENT
SEQUENCE:5
DTSTART;TZID=US/Pacific:20021028T140000
DTSTAMP:20021028T011706Z
SUMMARY:Coffee with Jason
UID:EC9439B1-FF65-11D6-9973-003065F99D04
DTEND;TZID=US/Pacific:20021028T150000
END:VEVENT
END:VCALENDAR
但是当我尝试解析它时,我得到了异常:
第 1 行错误:应为 [VCALENDAR],读取 [VCALENDARBEGIN]
相关代码为:
HttpHelper httpHelper = new HttpHelper(
"http://10.0.2.2/getcalendar.php", params);
StringBuilder response = httpHelper.postData();
StringReader sin = new StringReader(response.toString());
CalendarBuilder builder = new CalendarBuilder();
Calendar cal = null;
try {
cal = builder.build(sin);
} catch (IOException e) {
Log.d("calendar", "io exception" + e.getLocalizedMessage());
} catch (ParserException e) {
Log.d("calendar", "parser exception" + e.getLocalizedMessage());
public class HttpHelper {
final HttpClient client;
final HttpPost post;
final List<NameValuePair> data;
public HttpHelper(String address, List<NameValuePair> data) {
client = new DefaultHttpClient();
post = new HttpPost(address);
this.data = data;
}
private class GetResponseTask extends AsyncTask<Void, Void, StringBuilder> {
protected StringBuilder doInBackground(Void... arg0) {
try {
HttpResponse response = client.execute(post);
return inputStreamToString(response.getEntity().getContent());
} catch (ClientProtocolException e) {
} catch (IOException e) {
}
return null;
}
}
public StringBuilder postData() {
try {
post.setEntity(new UrlEncodedFormEntity(data));
return (new GetResponseTask().execute()).get();
} catch (UnsupportedEncodingException e) {
} catch (InterruptedException e) {
} catch (ExecutionException e) {
}
return null;
}
private StringBuilder inputStreamToString(InputStream is)
throws IOException {
String line = "";
StringBuilder total = new StringBuilder();
// Wrap a BufferedReader around the InputStream
BufferedReader rd = new BufferedReader(new InputStreamReader(is));
// Read response until the end
while ((line = rd.readLine()) != null) {
total.append(line);
Log.v("debug", "Line: " + line);
}
// Return full string
return total;
}
}
最佳答案
我的猜测是响应字符串中的行结尾与 ical4j 所期望的不同。
标准指定您应该使用 CRLF(又名“\r\n”)。
关于java - 解析 ical 格式 - 解析异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7300494/
我有一个包含 iCal 事件信息的文件 (/test.txt)。 Friday, May 6, 2011 4:00:00 PM 05/08/2011 11:20:00 PM summary locat
我正在尝试反序列化 iCal 文件,然后将集合映射到自定义 POCO。问题是我不确定属性存储在哪里。 这是反序列化方法 public static IICalendarCollection Deser
我正在尝试在收到通知后立即从 iCal 中删除事件。仅当 iCal 在后台时,事件才会被删除。如果在关闭 iCal 后发送相同的通知,则事件不会被删除。我正在尝试在 MyCalendar.m 中使用此
我正在使用 DDay.iCal 创建 iCal 源.它有效,但我不知道如何设置提要的时区。这是基本代码: iCalendar iCal = new iCalendar(); // (); evt.St
您好,我正在从 DDay.ical 迁移到 Ical.Net nuget pacakages,但我被困在以下代码中,该代码在 DDay.Ical 日历中添加了时区,请帮忙 上一个代码: List ls
我正在编写一个 Mac 应用程序。在这个应用程序中,我想让用户将一些元素变成日历事件。我希望用户能够将元素拖到 iCal 中,最好也拖到 BusyCal 中。但我不知道在拖动粘贴板上放什么。 我希望能
问题 一些重复发生的事件并没有真正在某个时候结束(比如俱乐部 session ?),取决于其他条件(比如假期)。但是,每年都需要手动添加这些异常(exception)情况,因为日期可能不同。 研究 我
我试图了解 iCal feed 和 iCalendar 客户端如何处理过去和 future 的大量事件。有没有什么方法可以让 iCalendar 客户端将日期范围传达给 iCalendar 提要,以便
已结束。此问题正在寻求书籍、工具、软件库等的推荐。它不满足Stack Overflow guidelines 。目前不接受答案。 我们不允许提出寻求书籍、工具、软件库等推荐的问题。您可以编辑问题,以便
我正在尝试制作一个在互联网上找到的脚本来处理我的 ics 文件,以便我可以将其添加到我的项目中。 如果我从 ics 文件中删除时区部分,该脚本可以正常工作。但因为该文件将从互联网上动态获取,所以我无法
我正在处理一个现有的 ical 文件。我不确定是谁创建的,我想在联系他们之前更加熟悉 ical - 这样我就可以进行明智的对话。 谁能告诉我一个很好的 iCal 初学者教程? 到目前为止,我发现的大部
我只能找到获得 ISO 8601 周的算法(周从星期一开始)。 然而,iCal规范说 A week is defined as a seven day period, starting on the
也许是个愚蠢的问题,但我想知道 iCal 客户端如何查询远程日历。 我刚刚创建了一个生成 iCal 文件的小型 Web 服务。这个文件被 Google Calendar 和 Lightning(新 S
我目前正在用 php 编写一个 .ics 文件。我想知道 VEVENT 是否总是需要有一个结束日期? 比如……这是允许的吗? BEGIN:VEVENT UID:d3f760e29fa3f482199f
我编写了一个脚本来根据我数据库中的事件生成一个 iCal 日历。这是一个示例输出: BEGIN:VCALENDAR VERSION:2.0 PRODID:-//hacksw/handcal//NONS
我正在尝试编写一个 AppleScript 来查询 iCal 并在任何日历中查找给定日期的所有事件。 我首先编写了一个简单的脚本,它对给定日历中的每个事件执行一些简单的操作: tell applica
我正在我的应用程序中设置提醒。我已使用 EKEvent 将自定义事件添加到 iCal。现在,当我从 iCal 检索事件时,我会获取当天发生的所有事件。有没有办法仅获取/检索通过我的应用程序添加的事件,
iCal 附件能否在 description 属性中包含 HTML?如果是这样,有什么限制? 最佳答案 经过一些研究和测试。答案是否定的。意思是:你可以把它扔进去,但你不应该。 RFC 并没有严格禁止
我正在尝试弄清楚如何在 iCal 文件的“描述”部分中对换行符进行编码,以便它们能够正确导入到 Outlook、Google 日历和 Apple 日历中。 我继承的原始代码使用“=0D=0A”和引用打
首先我看过这个问题here和 here这对解决我的问题没有帮助: 我正在使用此处稍微修改过的 ics.js 代码 github link var ics = function() { 'use str
我是一名优秀的程序员,十分优秀!