I have been given the task of implementing a way to convert a string received through a JSON object to an iCalendar object(ics). I found the iCal4j library and have been attempting to use that as my parser. however it seems that the CalendarBuilder takes an InputStream.
How do I proceed ?
String response = jsonObj.getString("icalendar");
CalendarBuilder calBuiler = new CalendarBuilder();
Calendar calendar = calBuilder.build("???");
....
Edit : Would this work?
public Calendar convertStringtoCalendar(String arg)
{
CalendarBuilder calBuiler = new CalendarBuilder();
InputStream is;
try {
is = new ByteArrayInputStream(arg.getBytes("UTF-8"));
return calBuiler.build(is);
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ParserException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
Solved the problem by doing the following.