小编Jar*_*ofy的帖子

使用Java编写.ics iCal文件

我正在尝试使用java实现我自己的iCal创建者,由于某种原因,我无法识别我的.ics文件。我想知道我做错了什么,我可以得到与维基百科的示例完全一样的输出。.ics文件和程序生成后的文件之间有什么区别。

他们的例子:

BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//hacksw/handcal//NONSGML v1.0//EN
BEGIN:VEVENT
UID:uid1@example.com
DTSTAMP:19970714T170000Z
ORGANIZER;CN=John Doe:MAILTO:john.doe@example.com
DTSTART:19970714T170000Z
DTEND:19970715T035959Z
SUMMARY:Bastille Day Party
END:VEVENT
END:VCALENDAR
Run Code Online (Sandbox Code Playgroud)

我的.ics文件

BEGIN:VCALENDAR 
VERSION:1.0 
PRODID://Elara/lofy/tanare/delp/314sum2015// 
BEGIN:VEVENT 
UID:uid1@example.com
DTSTAMP:19970714T170000Z
ORGANIZER;CN=John Doe:MAILTO:john.doe@example.com
DTSTART:19970714T170000Z
DTEND:19970715T035959Z
SUMMARY:Bastille Day Party
END:VEVENT 
END:VCALENDAR 
Run Code Online (Sandbox Code Playgroud)

这是用于生成.ics文件的代码。

    import java.io.FileWriter;
    import java.io.IOException;
    import java.io.PrintWriter;
    import java.util.ArrayList;

    public class iCal {

    private String version =    "VERSION:1.0 \n";
    private String prodid =     "PRODID://Elara/lofy/tanare/delp/314sum2015// \n";
    private String calBegin =   "BEGIN:VCALENDAR \n";
    private String calEnd =     "END:VCALENDAR \n";
    private String eventBegin = "BEGIN:VEVENT \n";
    private String eventEnd …
Run Code Online (Sandbox Code Playgroud)

java icalendar

5
推荐指数
2
解决办法
2万
查看次数

Prolog - 检查列表是否为空 []

我只是想弄清楚如何检查列表是否为空,我整理了一些检查列表长度的东西,另外还应该检查列表是否为空。

% Gives the length of a list.
listlength([]     , 0 ).
listlength([_|Xs] , L ):- 
    listlength(Xs,N), 
    L is N+1. 

% checks to see that the length of the list is greater than or equal to 3 and not empty.
check_length( [] ).
check_length( L  ):-
    listlength(L, Len),
    Len >= 3,
    L \== [].    %This is the bit of code I'm having problems with 
                  it should be false if the list is just [] or empty.
Run Code Online (Sandbox Code Playgroud)

我是一名学生,所以我不一定需要一个直接的答案,我只是想弄清楚我做错了什么。

list prolog

5
推荐指数
1
解决办法
2万
查看次数

标签 统计

icalendar ×1

java ×1

list ×1

prolog ×1