Now, if the file does not exist, I want to create it, like so:
Also, the missing directory structure will be created.
My problem now is that when the caller passes a directory rather than a file such as '/root/dir/' the FileOutputStream cannot be created and throws an exception. The missing directories have been created, which I don't want.
So, how do I determine whether or not a file that doesnt exist yet is a directory or not?
thanks
JDBCSupport - An easy to use, light-weight JDBC framework -
So, how do I determine whether or not a file that doesnt exist yet is a directory or not?
That question makes no sense. A file that doesn't exist could be anything, including a device, a symlink, anything. Unless you can form the input in a consistent way what you're asking to do is impossible.
So, how do I determine whether or not a file that doesnt exist yet is a directory or not?
That question makes no sense. A file that doesn't exist could be anything, including a device, a symlink, anything. Unless you can form the input in a consistent way what you're asking to do is impossible.
+1
Sebastian, you can have one little fix in your code that should at least remove any errors:
The parent folder will be created this way without creating a folder for the resource file itself.