commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Holger Hoffstätte (JIRA) <>
Subject [jira] Commented: (IO-77) [io] add a convenience FileUtils.move(File src, File dest)
Date Mon, 07 Jan 2008 17:38:34 GMT


Holger Hoffstätte commented on IO-77:

Sigh..I really didn't want to turn this into a quasi-religious discussion about the merits
of Javas already messed up exception handling. You do not have to agree with using IAE; I
don't agree with a lot of things either :-)

I actually agree with you that using IAE could be considered "inconsistent" under the assumption
that "the majority of methods out there do not check their parameters". However, the rest
of commons-* (in this case IO) _does_, so within the boundaries of *this library* the assumption
is false. My main beef with throwing NPE is that is effectively inverts the meaning of the
exception, thus making it arbitrary. Whether we check & throw exceptions or not at all
is an entirely different aspect.

Finally I do take issue with your statement that "The argument that people will catch NullPointerException
isn't valid", if only because I have _seen_ precisely that in oh so holy "production code",
belive it or not - and yes it did cover up unrelated NPEs. Why people do that is irrelevant.
People do a lot of stupid things, but that doesn't mean that a library should encourage or
enable them to do so.

> [io] add a convenience FileUtils.move(File src, File dest)
> ----------------------------------------------------------
>                 Key: IO-77
>                 URL:
>             Project: Commons IO
>          Issue Type: Improvement
>          Components: Utilities
>    Affects Versions: 1.0
>         Environment: Operating System: other
> Platform: Other
>            Reporter: nicolas de loof
>            Priority: Minor
>             Fix For: 1.4
>         Attachments: IO-77.patch, patch_io.txt
> I'm using FileUtils as it partially solves the missing "move" method for File,
> that is so simple to do in unix shell.
> A full implementation in FileUtils may be great :
> static boolean FileUtils.move(File src, File dest)
> throws IOException
> {
>     boolean rename = src.renameTo(dest);
>     if (!rename)
>     {
>         copyFile(file, dest);
>         file.delete();
>     }
> }

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

View raw message