On Sun, Feb 17, 2013 at 4:56 AM, Thomas Neidhart <thomas.neidh...@gmail.com>wrote:
> On 02/17/2013 12:13 AM, Thad Humphries wrote: > > I am using Commons Codec v1.7 to Base64 encode a TIFF file for writing to > > an XML file as CDATA. Simple: > > > > File file = new File(fileName); > > FileInputStream fis = new FileInputStream(file); > > ByteArrayOutputStream baos = new ByteArrayOutputStream(); > > Base64OutputStream b64os = new Base64OutputStream(baos); > > int bufSize = 8 * 1024; > > byte [] buffer = new byte[bufSize]; > > int count; > > while ((count = fis.read(buffer, 0, bufSize)) != -1) > > b64os.write(buffer, 0, count); > > fis.close(); > > baos.flush(); > > b64os.close(); > > baos.close(); > > xtw.writeCData(new String(baos.toByteArray())); > > > > However I'm concerned that a future version Commons Codec of might not > > default to chunked output. So I'd like to swap > > > > Base64OutputStream b64os = new Base64OutputStream(baos); > > > > for > > > > byte [] eol = {0xD, 0xA}; > > Base64OutputStream b64os = new Base64OutputStream(baos, true, 76, > > eol); > > > > However when I do this, the program crashes out on creating "new > > Base64OutputStream(...)". If fact, it skips right past a catch on > Exception > > and goes directly to finally (honest--my logger shows nothing and I've > > watched this dozens of times in Eclipse's deugger). > > > > Am I doing something wrong? > > Hi Thad, > > I just tried your example and this works pretty fine for me. Could you > please post the exception you are getting? > > Thomas > Hi Thomas, Thanks for the response. The call does not catch as an Exception, but just now I found that it catches as a Throwable. My log4j log is below. Line 1703 is where I instantiate Base64OutputStream: Base64OutputStream b64os = new Base64OutputStream(baos, true, 76, eol); >From the log. java.lang.VerifyError: (class: org/apache/commons/codec/binary/Base64OutputStream, method: <init> signature: (Ljava/io/OutputStream;ZI[B)V) Incompatible argument to function at com.optix.cold.server.ColdServicesImpl.makeColdFormFile(ColdServicesImpl.java:1703) at com.optix.cold.server.ColdServicesImpl.saveColdForm(ColdServicesImpl.java:1339) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:561) at com.google.gwt.user.server.rpc.RemoteServiceServlet.processCall(RemoteServiceServlet.java:208) at com.google.gwt.user.server.rpc.RemoteServiceServlet.processPost(RemoteServiceServlet.java:248) at com.google.gwt.user.server.rpc.AbstractRemoteServiceServlet.doPost(AbstractRemoteServiceServlet.java:62) at javax.servlet.http.HttpServlet.service(HttpServlet.java:637) at javax.servlet.http.HttpServlet.service(HttpServlet.java:717) at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487) at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1097) at com.optix.cold.server.GWTCacheControlFilter.doFilter(GWTCacheControlFilter.java:52) at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1088) at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:360) at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216) at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181) at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:729) at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:405) at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152) at org.mortbay.jetty.handler.RequestLogHandler.handle(RequestLogHandler.java:49) at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152) at org.mortbay.jetty.Server.handle(Server.java:324) at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:505) at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:843) at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:647) at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:205) at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:380) at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:395) at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:488) -- "Hell hath no limits, nor is circumscrib'd In one self-place; but where we are is hell, And where hell is, there must we ever be" --Christopher Marlowe, *Doctor Faustus* (v, 121-24)