commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thad Humphries <>
Subject [codec] problem with Base64OutputStream
Date Sat, 16 Feb 2013 23:13:25 GMT
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 =, 0, bufSize)) != -1)
          b64os.write(buffer, 0, count);
        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);


        byte [] eol = {0xD, 0xA};
        Base64OutputStream b64os = new Base64OutputStream(baos, true, 76,

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?

"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)

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message