Package org.fugerit.java.core.util
Class PropsIO
- java.lang.Object
-
- org.fugerit.java.core.util.PropsIO
-
public final class PropsIO extends Object
Utility for handling java.util.Property objects.
- Author:
- Fugerit
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
fill(Properties from, Properties to)
Copy all entries from a java.util.Properties to another.static Properties
loadFromBundle(ResourceBundle bundle)
static Properties
loadFromClassLoader(String path)
Load a java.util.Properties from the DefaultClassLoader.static Properties
loadFromClassLoaderSafe(String path)
Load a java.util.Properties from the DefaultClassLoader.static Properties
loadFromFile(File f)
Load a java.util.Properties from a File.static Properties
loadFromFile(String f)
Load a java.util.Properties from a File.static Properties
loadFromFileSafe(String f)
Load a java.util.Properties from a File.static Properties
loadFromStream(InputStream is)
Load a java.util.Properties from a Stream.static Properties
loadFromURL(String u)
Load a java.util.Properties from an URL.static Properties
loadFromURL(URL u)
Load a java.util.Properties from an URL.static Properties
subProps(Properties props, String prefix)
Return a newjava.util.Properties
object containing only the properties with given prefix.static Properties
subProps(Properties props, String prefix, boolean removePrefix)
Return a newjava.util.Properties
object containing only the properties with given prefix.static Properties
subProps(Properties props, String basePrefix, String separator)
Return a newjava.util.Properties
object containing only the properties with given prefix.static Properties
subProps(Properties props, String basePrefix, String separator, boolean removePrefix)
Return a newjava.util.Properties
object containing only the properties with given prefix.
-
-
-
Method Detail
-
fill
public static void fill(Properties from, Properties to)
Copy all entries from a java.util.Properties to another.
No check is made for overwritten entries.
- Parameters:
from
- source objectto
- destination object- See Also:
ClassHelper
-
loadFromClassLoaderSafe
public static Properties loadFromClassLoaderSafe(String path)
Load a java.util.Properties from the DefaultClassLoader.
- Parameters:
path
- the path- Returns:
- the java.util.Properties object
-
loadFromClassLoader
public static Properties loadFromClassLoader(String path) throws IOException
Load a java.util.Properties from the DefaultClassLoader.
- Parameters:
path
- the path- Returns:
- the java.util.Properties object
- Throws:
IOException
- in case of troubles during the operation
-
loadFromURL
public static Properties loadFromURL(String u) throws IOException
Load a java.util.Properties from an URL.
- Parameters:
u
- the url- Returns:
- the java.util.Properties object
- Throws:
IOException
- in case of troubles during the operation
-
loadFromURL
public static Properties loadFromURL(URL u) throws IOException
Load a java.util.Properties from an URL.
- Parameters:
u
- the url- Returns:
- the java.util.Properties object
- Throws:
IOException
- in case of troubles during the operation
-
loadFromFile
public static Properties loadFromFile(String f) throws IOException
Load a java.util.Properties from a File.
- Parameters:
f
- the file- Returns:
- the java.util.Properties object
- Throws:
IOException
- in case of troubles during the operation
-
loadFromFileSafe
public static Properties loadFromFileSafe(String f)
Load a java.util.Properties from a File.
- Parameters:
f
- the file- Returns:
- the java.util.Properties object
-
loadFromFile
public static Properties loadFromFile(File f) throws IOException
Load a java.util.Properties from a File.
- Parameters:
f
- the file- Returns:
- the java.util.Properties object
- Throws:
IOException
- in case of troubles during the operation
-
loadFromStream
public static Properties loadFromStream(InputStream is) throws IOException
Load a java.util.Properties from a Stream.
- Parameters:
is
- the stream- Returns:
- the java.util.Properties object
- Throws:
IOException
- in case of troubles during the operation
-
subProps
public static Properties subProps(Properties props, String basePrefix, String separator)
Return a newjava.util.Properties
object containing only the properties with given prefix. NOTE: by default prefix is removed in resulting Properties NOTE: prefix is build as basePrefix+separator- Parameters:
props
- input java.util.PropertiesbasePrefix
- base prefix to use for searching keysseparator
- separator to use for searching keys- Returns:
- resulting java.util.Properties
-
subProps
public static Properties subProps(Properties props, String basePrefix, String separator, boolean removePrefix)
Return a newjava.util.Properties
object containing only the properties with given prefix. NOTE: prefix is build as basePrefix+separator- Parameters:
props
- input java.util.PropertiesbasePrefix
- base prefix to use for searching keysseparator
- separator to use for searching keysremovePrefix
-true
in case you want to remove the prefix from keys in the resulting Properties- Returns:
- resulting java.util.Properties
-
subProps
public static Properties subProps(Properties props, String prefix)
Return a newjava.util.Properties
object containing only the properties with given prefix. NOTE: by default prefix is removed in resulting Properties- Parameters:
props
- input java.util.Propertiesprefix
- prefix for the keys to search- Returns:
- resulting java.util.Properties
-
subProps
public static Properties subProps(Properties props, String prefix, boolean removePrefix)
Return a newjava.util.Properties
object containing only the properties with given prefix.- Parameters:
props
- input java.util.Propertiesprefix
- prefix for the keys to searchremovePrefix
-true
in case you want to remove the prefix from keys in the resulting Properties- Returns:
- resulting java.util.Properties
-
loadFromBundle
public static Properties loadFromBundle(ResourceBundle bundle)
-
-