[
https://issues.apache.org/jira/browse/IO-112?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Henri Yandell updated IO-112:
-----------------------------
Fix Version/s: (was: 1.4)
1.3.1
> NPE in FileUtils.openOutputStream(File) when file has no parent in path.
> ------------------------------------------------------------------------
>
> Key: IO-112
> URL: https://issues.apache.org/jira/browse/IO-112
> Project: Commons IO
> Issue Type: Bug
> Components: Utilities
> Affects Versions: 1.3
> Environment: Sun Java 1.4.2_13.
> Windows XP SP2 + current patches.
> Eclipse 3.3M4.
> Reporter: Gary Gregory
> Assigned To: Gary Gregory
> Fix For: 1.3.1
>
>
> -----Original Message-----
> From: deng xinzi [mailto:[EMAIL PROTECTED]
> Sent: Sunday, February 04, 2007 6:19 AM
> To: [email protected]
> Subject: [bug]commons-io 1.3 FileUtils.openOutputStream(File file)
> NullPointException
> 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 ...
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]