commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Henri Yandell (JIRA)" <j...@apache.org>
Subject [jira] Updated: (IO-112) NPE in FileUtils.openOutputStream(File) when file has no parent in path.
Date Fri, 09 Feb 2007 00:28:05 GMT

     [ 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:xinzi6388@gmail.com] 
> Sent: Sunday, February 04, 2007 6:19 AM
> To: commons-dev@jakarta.apache.org
> 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: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message