1 package org.codehaus.plexus.util;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 import java.io.File;
20 import java.io.IOException;
21 import java.io.InputStream;
22 import java.net.URL;
23 import java.nio.file.Files;
24 import java.util.Objects;
25 import java.util.Properties;
26
27
28
29
30
31
32
33 public class PropertyUtils {
34
35 public static Properties loadProperties(final URL url) throws IOException {
36 return loadProperties(Objects.requireNonNull(url, "url").openStream());
37 }
38
39 public static Properties loadProperties(final File file) throws IOException {
40 return loadProperties(
41 Files.newInputStream(Objects.requireNonNull(file, "file").toPath()));
42 }
43
44 public static Properties loadProperties(final InputStream is) throws IOException {
45 final Properties properties = new Properties();
46
47
48 if (is != null) {
49 try (InputStream in = is) {
50 properties.load(in);
51 }
52 }
53
54 return properties;
55 }
56 }