
org.codehaus.plexus.util.PropertyUtils Maven / Gradle / Ivy
Go to download
A collection of various utility classes to ease working with strings, files, command lines, XML and more.
package org.codehaus.plexus.util;
import java.util.Properties;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.io.IOException;
import java.net.URL;
/**
*
*
* @author Jason van Zyl
* @author Michal Maczka
*
* @version $Id: PropertyUtils.java 1106 2004-10-07 19:29:57Z jdcasey $
*/
public class PropertyUtils
{
public static Properties loadProperties( URL url )
{
try
{
return loadProperties( url.openStream() );
}
catch ( Exception e )
{
// ignore
}
return null;
}
public static Properties loadProperties( File file )
{
try
{
return loadProperties( new FileInputStream( file ) );
}
catch ( Exception e )
{
// ignore
}
return null;
}
public static Properties loadProperties( InputStream is )
{
try
{
Properties properties = new Properties();
// Make sure the properties stream is valid
if ( is != null )
{
properties.load( is );
}
return properties;
}
catch ( IOException e )
{
// ignore
}
finally
{
try
{
if ( is != null )
{
is.close();
}
}
catch ( IOException e )
{
// ignore
}
}
return null;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy