我正在研究ical4j,并且在构建日历时存在解析错误。 .ics文件中没有非法字符。如何克服它?

时间:2015-01-17 11:22:35

标签: ical4j

这是我用于使用ical4j的CalendarBuilder类构建.ics文件的代码。之前我使用的是FileInputStream而不是缓冲区,但是出现了“PushBackBuffer Overflow”错误。我使用了另一种方法来增加缓冲区的大小,我发现了这个错误。

Calendar c=new Calendar();
            try
                {br=new BufferedReader( new InputStreamReader(new FileInputStream(new File("D:\\calendar.ics"))),3000);
                }
                catch(FileNotFoundException e)
                {
                    e.printStackTrace();
                }
                try
                {
                    UnfoldingReader reader = new UnfoldingReader(br, 3000);
                    c=builder.build(reader);
        }
                catch(Exception e)
                {
                    e.printStackTrace();
                }

    ERROR:
    [Fatal Error] :1:1: Content is not allowed in prolog.
    net.fortuna.ical4j.data.ParserException: Error at line 1:Could not parse XML
        at net.fortuna.ical4j.data.HCalendarParser.parse(HCalendarParser.java:224)
        at net.fortuna.ical4j.data.HCalendarParser.parse(HCalendarParser.java:212)
        at net.fortuna.ical4j.data.CalendarBuilder.build(CalendarBuilder.java:210)
        at hello.CalendarRepository.createEvent(CalendarRepository.java:122)
        at hello.CalendarEndpoint.createEventRequest(CalendarEndpoint.java:71)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at org.springframework.ws.server.endpoint.MethodEndpoint.invoke(MethodEndpoint.java:134)
        at org.springframework.ws.server.endpoint.adapter.DefaultMethodEndpointAdapter.invokeInternal(DefaultMethodEndpointAdapter.java:291)
        at org.springframework.ws.server.endpoint.adapter.AbstractMethodEndpointAdapter.invoke(AbstractMethodEndpointAdapter.java:55)
        at org.springframework.ws.server.MessageDispatcher.dispatch(MessageDispatcher.java:236)
        at org.springframework.ws.server.MessageDispatcher.receive(MessageDispatcher.java:176)
        at org.springframework.ws.transport.support.WebServiceMessageReceiverObjectSupport.handleConnection(WebServiceMessageReceiverObjectSupport.java:89)
        at org.springframework.ws.transport.http.WebServiceMessageReceiverHandlerAdapter.handle(WebServiceMessageReceiverHandlerAdapter.java:61)
        at org.springframework.ws.transport.http.MessageDispatcherServlet.doService(MessageDispatcherServlet.java:293)
        at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:961)
        at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:863)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:646)
        at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:837)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
        at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:77)
        at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:108)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
        at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:503)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:421)
        at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1070)
        at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:611)
        at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1736)
        at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1695)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
        at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
        at java.lang.Thread.run(Thread.java:744)
    Caused by: org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 1; Content is not allowed in prolog.
        at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:257)
        at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:347)
        at net.fortuna.ical4j.data.HCalendarParser.parse(HCalendarParser.java:217)
        ... 42 more

0 个答案:

没有答案