FileUtils.openOutputStream(File file) When the file = new File( "abc.txt" ); There will be a NullPointerException throw. Cause file = new File("abc.txt") file.getParentFile() returns null.
So I suggest adding the null check code like this. File parent = file.getParentFile(); if( parent != null ) { // ADD THIS!!! if (parent.exists() == false) { if (parent.mkdirs() == false) { throw new IOException("File '" + file + "' could not be created"); } } } Xinzi ...