File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed
src/main/java/org/scijava/test Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change 4444 * A bunch of helpful functions for unit tests.
4545 *
4646 * @author Johannes Schindelin
47+ * @author Curtis Rueden
4748 */
4849public class TestUtils {
4950
51+ /**
52+ * Creates an empty file at the given path, creating intermediate directories
53+ * as necessary.
54+ *
55+ * @param parent The parent directory of the relative path.
56+ * @param path The forward-slash-separated path to create.
57+ * @return a {@link File} pointing at the newly created empty path.
58+ * @throws IOException if the file cannot be created.
59+ */
60+ public static File createPath (final File parent , final String path )
61+ throws IOException
62+ {
63+ File file = parent ;
64+ final String [] elements = path .split ("/" );
65+ for (int i =0 ; i <elements .length ; i ++) {
66+ file = new File (file , elements [i ]);
67+ if (i == elements .length - 1 ) file .createNewFile ();
68+ else file .mkdir ();
69+ }
70+ return file ;
71+ }
72+
5073 /**
5174 * Makes a temporary directory for use with unit tests.
5275 * <p>
You can’t perform that action at this time.
0 commit comments