Convert PDF to Base64 and store data to BLOB of Database
===

I want to binary data (e.g. a PDF) into a BLOB of my Oracle database.
At first I putted the PDF into a FileInputStream and created a byte-array.Here is the code for that:

    public static byte[] createByteArray(File pCurrentFolder, String pNameOfBinaryFile)
    	{
    		
    		String pathToBinaryData = pCurrentFolder.getAbsolutePath()+"/"+pNameOfBinaryFile;
    		
    		File file = new File(pathToBinaryData);
    		if (!file.exists())
    		{
    			System.out.println(pNameOfBinaryFile+" could not be found in folder "+pCurrentFolder.getName());
    			return null;
    		}
    		
    		FileInputStream fin = null;
    		try {
    			fin = new FileInputStream(file);
    		} catch (FileNotFoundException e) {
    			e.printStackTrace();
    		}
    
    		byte fileContent[] = new byte[(int) file.length()];
    
    		try {
    			fin.read(fileContent);
    		} catch (IOException e) {
    			e.printStackTrace();
    		}
    		
    		return fileContent;
    	}

 I sent this (the byte array) via MyBatis to the database and it worked, so that I had the PDF in my BLOB and I also could read the PDF from my database.
But now I face the following problem:
I have a JDBC Connector for my search engine (FAST ESP...but that dowsnt matter) which connects to a certain database and stores all the content to a xml file. Inside this xml file is an element called "data" which contains the binary data inside its CDATA Field.

When I want to parse this xml, Java tells me: 
 

    The content of elements must consist of well-formed character data or markup.

With some PDF's i works but with some not. So I think the problem is, that I have stored them in the database in the wrong way.

For further information I would reverence to another questions I asked before which is similar to that.

http://stackoverflow.com/questions/11735416/java-skip-binary-data-in-xml-file-while-parsing

Someone there told me that I should encode my PDF (or any binary file) with base64. So that would mean, I do not just put my PDF into a FileInputStream, store the byte[] and put this byte[] to my BLOB of the database.
What do I have to do, to store the PDF in correct way inside my database, so that afterwards I can correctly parse my XML file the JDBC connector creates?
