public void writeCalendarToOutputStream(final OutputStream stream) { try { CalendarOutputter outputter = new CalendarOutputter(); outputter.output(this.calendar, stream); } catch (IOException e) { log.error("Error while exporting calendar " + e.getMessage()); } }
/** * Writes an iCalendar string representing the calendar items * contained within the given calendar collection to the given * output stream. * * Since the calendar content stored with each calendar items * is parsed and validated when the item is created, these * errors should not reoccur when the calendar is being * outputted. * * @param collection the <code>CollectionItem</code> to format * * @throws IllegalArgumentException if the collection is not * stamped as a calendar collection * @throws IOException */ public static void output(Calendar calendar, OutputStream out) throws IOException { CalendarOutputter outputter = new CalendarOutputter(); outputter.setValidating(false); try { outputter.output(calendar, out); } catch (ValidationException e) { throw new IllegalStateException("unable to validate collection calendar", e); } } }
/** * Outputs an iCalender string to the specified output stream. * @param calendar calendar to write to ouput stream * @param out an output stream * @throws IOException thrown when unable to write to output stream * @throws ValidationException where calendar validation fails */ public final void output(final Calendar calendar, final OutputStream out) throws IOException, ValidationException { output(calendar, new OutputStreamWriter(out, DEFAULT_CHARSET)); }
/** * Return the CalendarOuputter instance. * @return CalendarOutputter */ protected synchronized CalendarOutputter getCalendarOutputterInstance(){ if (calendarOutputter == null){ calendarOutputter = new CalendarOutputter(validatingOutputter); } return calendarOutputter; }
/** * Outputs an iCalender string to the specified writer. * @param calendar calendar to write to writer * @param out a writer * @throws IOException thrown when unable to write to writer * @throws ValidationException where calendar validation fails */ public final void output(final Calendar calendar, final Writer out) throws IOException, ValidationException { if (isValidating()) { calendar.validate(); } try (FoldingWriter writer = new FoldingWriter(out, foldLength)) { writer.write(calendar.toString()); } } }
/** * Outputs an iCalender string to the specified output stream. * @param calendar calendar to write to ouput stream * @param out an output stream * @throws IOException thrown when unable to write to output stream * @throws ValidationException where calendar validation fails */ public final void output(final Calendar calendar, final OutputStream out) throws IOException, ValidationException { output(calendar, new OutputStreamWriter(out, DEFAULT_CHARSET)); }
outputter = new CalendarOutputter(); outputter.output(calendar, fout); return true;
/** * Outputs an iCalender string to the specified writer. * @param calendar calendar to write to writer * @param out a writer * @throws IOException thrown when unable to write to writer * @throws ValidationException where calendar validation fails */ public final void output(final Calendar calendar, final Writer out) throws IOException, ValidationException { if (isValidating()) { calendar.validate(); } try (FoldingWriter writer = new FoldingWriter(out, foldLength)) { writer.write(calendar.toString()); } } }
/** * Get IcalBody as ByteArray * * @return - calendar in ICS format as byte[] * @throws Exception * - in case of error during writing to byte array */ public byte[] getIcalAsByteArray() throws Exception { ByteArrayOutputStream bout = new ByteArrayOutputStream(); CalendarOutputter outputter = new CalendarOutputter(); outputter.output(icsCalendar, bout); return bout.toByteArray(); }
/** * Writes an iCalendar string representing the calendar items * contained within the given calendar collection to the given * output stream. * * Since the calendar content stored with each calendar items * is parsed and validated when the item is created, these * errors should not reoccur when the calendar is being * outputted. * * @param collection the <code>CollectionItem</code> to format * * @throws IllegalArgumentException if the collection is not * stamped as a calendar collection * @throws IOException */ public static void output(Calendar calendar, OutputStream out) throws IOException { CalendarOutputter outputter = new CalendarOutputter(); outputter.setValidating(false); try { outputter.output(calendar, out); } catch (ValidationException e) { throw new IllegalStateException("unable to validate collection calendar", e); } } }
/** * Outputs an iCalender string to the specified output stream. * @param calendar calendar to write to ouput stream * @param out an output stream * @throws IOException thrown when unable to write to output stream * @throws ValidationException where calendar validation fails */ public final void output(final Calendar calendar, final OutputStream out) throws IOException, ValidationException { output(calendar, new OutputStreamWriter(out, DEFAULT_CHARSET)); }
/** * Outputs an iCalender string to the specified writer. * @param calendar calendar to write to writer * @param out a writer * @throws IOException thrown when unable to write to writer * @throws ValidationException where calendar validation fails */ public final void output(final Calendar calendar, final Writer out) throws IOException, ValidationException { if (isValidating()) { calendar.validate(); } final FoldingWriter writer = new FoldingWriter(out, foldLength); try { writer.write(calendar.toString()); } finally { writer.close(); } } }
public ByteArrayOutputStream getCalendarAsByteStream() { try { ByteArrayOutputStream stream = new ByteArrayOutputStream(); CalendarOutputter outputter = new CalendarOutputter(); outputter.output(this.calendar, stream); return stream; } catch (IOException e) { log.error("Error while exporting calendar " + e.getMessage()); return null; } }
private byte[] calendarAsByteArray(net.fortuna.ical4j.model.Calendar calendar) throws FileNotFoundException { byte[] bytes; try { ByteArrayOutputStream output = new ByteArrayOutputStream(); CalendarOutputter outputter = new CalendarOutputter(); outputter.setValidating(false); outputter.output(calendar, output); bytes = output.toByteArray(); FileOutputStream fos = new FileOutputStream("test.ics"); fos.write(bytes); fos.close() } catch (Exception e) { throw new IllegalStateException("can't convert calendar to bytes: "+e); } return bytes; }
/** * Outputs an iCalender string to the specified output stream. * @param calendar calendar to write to ouput stream * @param out an output stream * @throws IOException thrown when unable to write to output stream * @throws ValidationException where calendar validation fails */ public final void output(final Calendar calendar, final OutputStream out) throws IOException, ValidationException { output(calendar, new OutputStreamWriter(out, DEFAULT_CHARSET)); }
/** * Outputs an iCalender string to the specified writer. * @param calendar calendar to write to writer * @param out a writer * @throws IOException thrown when unable to write to writer * @throws ValidationException where calendar validation fails */ public final void output(final Calendar calendar, final Writer out) throws IOException, ValidationException { if (isValidating()) { calendar.validate(); } final FoldingWriter writer = new FoldingWriter(out, foldLength); try { writer.write(calendar.toString()); } finally { writer.close(); } } }
/** * Convert Calendar object to String * @param calendar * @return string representation of calendar * @throws ValidationException - if something is wrong this exception is thrown. * @throws IOException - if something is wrong this exception is thrown. */ public static String outputCalendar(Calendar calendar) throws ValidationException, IOException { if (calendar == null) { return null; } CalendarOutputter outputter = new CalendarOutputter(); StringWriter sw = new StringWriter(); outputter.output(calendar, sw); return sw.toString(); }
CalendarBuilder builder = new CalendarBuilder(); FileInputStream fin = new FileInputStream(filename); CalendarOutputter outputter = new CalendarOutputter(false, FoldingWriter.REDUCED_FOLD_LENGTH); OutputStream out = new ByteArrayOutputStream(); outputter.setValidating(false); outputter.output(calendar, out);
/** * Outputs an iCalender string to the specified output stream. * @param calendar calendar to write to ouput stream * @param out an output stream * @throws IOException thrown when unable to write to output stream * @throws ValidationException where calendar validation fails */ public final void output(final Calendar calendar, final OutputStream out) throws IOException, ValidationException { output(calendar, new OutputStreamWriter(out, DEFAULT_CHARSET)); }
/** * Outputs an iCalender string to the specified writer. * @param calendar calendar to write to writer * @param out a writer * @throws IOException thrown when unable to write to writer * @throws ValidationException where calendar validation fails */ public final void output(final Calendar calendar, final Writer out) throws IOException, ValidationException { if (isValidating()) { calendar.validate(); } final FoldingWriter writer = new FoldingWriter(out, foldLength); try { writer.write(calendar.toString()); } finally { writer.close(); } } }