I am not completely sure about that. I intentionally didn't checked the return code from mkdirs. If mkdirs fails and a directory is not created then the subsequent createNewFile will fail. Therefore I'll detect an error situation and don't want to spend extra stats() to check for file-existance and file-type which is done in FileUtils.