1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.commons.io;
18
19 import java.io.File;
20 import java.io.InputStream;
21 import java.net.URI;
22 import java.net.URISyntaxException;
23 import java.net.URL;
24 import java.nio.file.Path;
25 import java.nio.file.Paths;
26
27
28
29
30 public class TestResources {
31
32 private static final String ROOT = "/org/apache/commons/io/";
33
34 public static File getFile(final String fileName) throws URISyntaxException {
35 return new File(getURI(fileName));
36 }
37
38 public static InputStream getInputStream(final String fileName) {
39 return TestResources.class.getResourceAsStream(ROOT + fileName);
40 }
41
42 public static Path getPath(final String fileName) throws URISyntaxException {
43 return Paths.get(getURI(fileName));
44 }
45
46 public static URI getURI(final String fileName) throws URISyntaxException {
47 return getURL(fileName).toURI();
48 }
49
50 public static URL getURL(final String fileName) {
51 return TestResources.class.getResource(ROOT + fileName);
52 }
53 }