public void forceByteCaching() {
        if (isCachingEnabled && !isCached) {
            try {
                // Create a writable file channel
                if (tempFile == null) {
                    createTempFile();
                }
                // create output stream in needed
                if (fileOutputStream == null) {
                    fileOutputStream = new FileOutputStream(tempFile);
                }
                // write the bytes to the cache.
                if (byteArrayOutputStream != null)
                    fileOutputStream.write(byteArrayOutputStream.toByteArray());

                isCached = true;

                // clear byte arrays to free up some memory.
                byteArrayOutputStream = null;
                byteArrayInputStream = null;
            } catch (IOException e) {
                logger.log(Level.FINE, "Error creating the temp file.", e);
            }
        }
    }