In addition to #372 please check that when opening the FileOutputStream the parent directory of the file exists (and create it if it doesn't). Have a look in commons-io at FileUtils.openOutputStream (here) or PathUtils.newOutputStream (here).
Both of those functions:
- Check that the parent directory of the file exists, if it does not then create it.
- Check that the file exists
- Check that the file is writable (not possible with 'path' API)