Well you used FileUtils.writeStringToFile() which is from Apache Commons. So you would need to have that library in an appropriate location or the classpath set appropriately to use it. The ArrayIndexOutOfBoundsException is due to an error on my part: (size -1) should've been size. The corrected version is at:
http://pastebin.com/E7zL000f
As for FileUtils: you used it, so I assumed that you knew what you were doing and since it appears to be from Apache Commons I added a corresponding import statement. Clearly I was wrong. :tongue:.