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