From 46b8db852c3cfce94591e5d32c0f39da42e66cad Mon Sep 17 00:00:00 2001 From: samskivert Date: Tue, 29 Sep 2009 23:41:06 +0000 Subject: [PATCH] Added newFile(base, part, part, ...). git-svn-id: https://samskivert.googlecode.com/svn/trunk@2640 6335cc39-0255-0410-8fd6-9bcaacd3b74c --- src/java/com/samskivert/util/FileUtil.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/java/com/samskivert/util/FileUtil.java b/src/java/com/samskivert/util/FileUtil.java index bb0f4c68..160ec3fb 100644 --- a/src/java/com/samskivert/util/FileUtil.java +++ b/src/java/com/samskivert/util/FileUtil.java @@ -38,6 +38,20 @@ import static com.samskivert.Log.log; */ public class FileUtil { + /** + * Creates a file from the supplied root using the specified child components. For example: + * fromPath(new File("dir"), "subdir", "anotherdir", "file.txt") creates a file + * with the Unix path dir/subdir/anotherdir/file.txt. + */ + public static File newFile (File root, String... parts) + { + File path = root; + for (String part : parts) { + path = new File(path, part); + } + return path; + } + /** * Recursively delete the specified directory and all files and * directories underneath it.