1 package org.apache.maven.shared.utils;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import java.io.FileInputStream;
23 import java.io.IOException;
24 import java.util.Properties;
25 import org.apache.maven.shared.utils.io.IOUtil;
26
27 import javax.annotation.Nonnull;
28 import javax.annotation.Nullable;
29
30
31
32
33 public class PropertyUtils
34 {
35
36 public PropertyUtils()
37 {
38
39 }
40
41 public static java.util.Properties loadProperties( @Nonnull java.net.URL url )
42 {
43 try
44 {
45 return loadProperties( url.openStream() );
46 }
47 catch ( Exception e )
48 {
49
50 }
51 return null;
52 }
53
54 public static java.util.Properties loadProperties( @Nonnull java.io.File file )
55 {
56 try
57 {
58 return loadProperties( new FileInputStream( file ) );
59 }
60 catch ( Exception e )
61 {
62
63 }
64 return null;
65 }
66
67 public static java.util.Properties loadProperties( @Nullable java.io.InputStream is )
68 {
69 try
70 {
71
72 Properties result = new Properties();
73 if ( is != null )
74 {
75 try
76 {
77 result.load( is );
78 }
79 catch ( IOException e )
80 {
81
82 }
83 }
84 return result;
85 }
86 catch ( Exception e )
87 {
88
89 }
90 finally
91 {
92 IOUtil.close( is );
93 }
94 return null;
95 }
96
97 }