Menu

Unexpected end of file Exception

Marc
2018-08-26
2018-08-28
  • Marc

    Marc - 2018-08-26

    I have currently no idea what´s here the issue and I asked kindly for help.

    I´m generating a ics - File. But if I would like to open the ics - File to get the Calender, I got the following error message:

    net.fortuna.ical4j.data.ParserException: Error at line 1:Unexpected end of file

    Here my information:
    ical4j Version 3.0.1
    Java: 8 Build 181

    My output from the ics - File:

    BEGIN:VCALENDAR
    PRODID:-//Ben Fortuna//iCal4j 1.0//EN
    VERSION:2.0
    CALSCALE:GREGORIAN
    BEGIN:VEVENT
    DTSTAMP:20180826T165052Z
    DTSTART:01180905T000000
    DTEND:01180905T000000
    SUMMARY:ddd
    TZID:Europe/Berlin
    UID:1535302250819-9ed0489f-0320-4a66-8f9c-4af0e62cdedd
    END:VEVENT
    END:VCALENDAR

    Here my code for generation the calender.ics - File:

    public void createEvent(BookingDate bookingDate, Mandatory mandatory, Employee employee)
            throws FileNotFoundException, IOException, ParserException, ConstraintViolationException {
    
        // Create a TimeZone
        System.setProperty("net.fortuna.ical4j.timezone.cache.impl", MapTimeZoneCache.class.getName());
    
        TimeZoneRegistry registry = TimeZoneRegistryFactory.getInstance().createRegistry();
        TimeZone timezone = registry.getTimeZone("Europe/Berlin");
        VTimeZone tz = timezone.getVTimeZone();
    
        String pathMandatoryFile = null;
        String pathEmployeeFile = null;
    
        // Reading the file and creating the calendar
        Calendar icsCalendar = null;
        FileOutputStream fout = null;
    
        if (bookingDate.isCreateCalendarMandatoryEntry()) {
            // timezone = registry.getTimeZone(mandatory.getTimeZone());
    
            pathMandatoryFile = "calendar.ics";
            fout = new FileOutputStream(pathMandatoryFile);
            try {
                FileInputStream fin = new FileInputStream(pathMandatoryFile);
                CalendarBuilder builder = new CalendarBuilder();
                icsCalendar = builder.build(fin);
            } catch (Exception e) {
    
            }
    
            if (icsCalendar == null) {
                icsCalendar = createNewCalender(pathMandatoryFile);
            }
        }
    

    Can you help me, please

     
  • LuckyLuigi

    LuckyLuigi - 2018-08-28

    I suspect you need to close your inputstream to flush the buffer

     

Log in to post a comment.