You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Tyler Barrus (JIRA)" <ji...@apache.org> on 2014/09/27 04:34:33 UTC

[jira] [Commented] (IO-416) FileUtil One-Up FileName

    [ https://issues.apache.org/jira/browse/IO-416?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14150349#comment-14150349 ] 

Tyler Barrus commented on IO-416:
---------------------------------

Perhaps something like incrementing the file name to the first non-collision name would suffice. Something like:
{code}
// input: /directory/test.txt is a file that exists
File f = incrementFileName(new File("/directory/test.txt"));
try {
	FileUtils.touch(f);
} catch (IOException e) {
	e.printStackTrace();
}

// output: a new file at /directory/test (1).txt
{code}

I have code to do this but need to work to get it in patch form. Once it is in a patch, I can post it here.

> FileUtil One-Up FileName
> ------------------------
>
>                 Key: IO-416
>                 URL: https://issues.apache.org/jira/browse/IO-416
>             Project: Commons IO
>          Issue Type: Wish
>          Components: Utilities
>            Reporter: BELUGA BEHR
>            Priority: Minor
>
> Create a FileNameUtil or FileUtil facility that allows for creating a one-up extension on files that already exist.
> example:
> archive
> +-- file.txt
> +-- file.txt.1
> +-- file.txt.2
> {code}
> File file = FileNameUtils.nextOneUpFile("/archive/file.txt");
> System.out.println(file)
> // output: /archive/file.txt.3
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)