buildhelper.java
来自「Java mulitplayer strategy game. Adaptati」· Java 代码 · 共 80 行
JAVA
80 行
package net.sf.jawp.util;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
/**
* helper for retrieving build specific data
* @author jarek
*
*/
public class BuildHelper
{
private static final Log LOG = Log.getLog(BuildHelper.class);
private static final String BUILD_PROPERTIES = "/build.properties";
private static final String BUILD_NR_PROPERTY = "build.nr";
private static final String DEFAULT_BUILD_NR = "build.local";
/**
* retrieves build nr as string
* @return
*/
public static String getBuildNR()
{
String defVal = DEFAULT_BUILD_NR;
final String sysBuild = System.getenv("build_number");
if ( sysBuild != null && sysBuild.length() > 0)
{
defVal = sysBuild;
}
return getProperty(BUILD_NR_PROPERTY, defVal);
}
/**
* returns full build description
* @return
*/
public static String getBuildDesc()
{
return "<" + getBuildNR() + ">";
}
private static String getProperty( final String name, final String defaultValue)
{
final InputStream is = BuildHelper.class.getResourceAsStream( BuildHelper.BUILD_PROPERTIES);
if ( is != null)
{
final Properties props = new Properties();
try
{
props.load( is );
return props.getProperty(name, defaultValue);
}
catch (final IOException e)
{
LOG.error(e, e);
}
finally
{
try
{
is.close();
}
catch (final IOException e)
{
LOG.error(e, e);
}
}
}
return defaultValue;
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?