k5n.us
X Home X X News X X Apps/Tools X X Support X X Downloads X X Articles X X Contact X
k5n Java Calendar Tools
 AboutLicensingPlansTutorialDownloadDevelopersLinks 

Tutorial

The Event object holds a single ical event and includes information Journal and Freebusy objects.)

Typically, the ICalendarParser object is the container for the ical data. (You can override this by creating your own class that implements the DataStore interface. If not, the ICalendarParser class will handle all storage of iCalendar data.) It includes an API for querying events for specific categories and/or time ranges.



Parsing an iCalendar File:


import java.io.File;
import java.io.BufferedReader;
import java.io.IOException;
import java.util.Vector;
import us.k5n.calendar.ICalendarParser;
import us.k5n.calendar.Event;
import us.k5n.calendar.Todo;

// ...

  ICalendarParser parser;
  File icalFile = new File ( "/tmp/example.ics" );
  try {
    BufferedReader r = new BufferedReader ( new FileReader ( icalFile ) );
    parser.parse ( r );
  } catch ( IOException e ) {
    // ... report error
  }
  r.close ();
  Vector events = parser.getAllEvents ();
  for ( int i = 0; i < events.size(); i++ ) {
    Event e = (Event) events.elementAt ( i );
    System.out.println ( "Event: " + e.getSummary () );
  }
  TodoList todo = parser.getAllTodo (); // get to-do entries
  for ( int i = 0; i < todo.size(); i++ ) {
    Todo t = (Todo) todo.elementAt ( i );
    System.out.println ( "Todo: " + t.getSummary () );
  }
// ...


Donate

SourceForge.net Logo

Valid XHTML 1.0 Valid CSS PHP
Page Last Updated: 02-Aug-2017
Copyright ©2004-2017 k5n.us, All Rights Reserved