Check Null ======> System.out.println( "actualValue ======> " + ( (actualValue != null)? actualValue: "NULL") );
Dynamically Getting parameters from a property file:
A Value in Property File:
FILE_NAME = ABC-rpt_{0}_{1}_WXD_{2}.out
How to populate FILE_NAME dynamically in Java:
Object[] args = {"Frank","Wang","2011-07-10"};
theFileName = PropertyFileHandler.getInstance().getProperty("FILE_NAME",args);
import java.io.InputStream;
import java.text.MessageFormat;
import java.util.Properties;
import org.apache.log4j.Logger;
public class PropertyFileHandler
{
private static final PropertyFileHandler instance = new PropertyFileHandler();
private static final String PROPERTY_PATH = "/myPropertyFile.properties";
private static final Logger log = Logger.getLogger(PropertyFileHandler.class);
private Properties props;
private PropertyFileHandler()
{
props = new Properties();
InputStream inputStream = getClass.getResourceAsStream(PROPERTY_PATH);
try {
props.load(inputStream);
}
catch(IOException ex) {
log.error( ex.getMessage() );
}
}
private PrppertyFileHandler(String filePath)
{
props = new Properties();
FileInputStream fileInputStream = getClass.getResourceAsStream(filePath);
try {
props.load(fileInputStream);
}
catch(IOException ex) {
log.error( ex.getMessage() );
}
}
private PrppertyFileHandler(Properties preperties)
{
props = properties;
}
public static PropertyFileHandler getInstance()
{
return instance;
}
public String getProperty(String propertyKey, Object[] args)
{
String theResult = "";
try {
theResult = props.getProperty(propertyKey);
theResult = MessageFormat.format( theResult, args);
}
catch(Exception ex) {
{
log.error( ex.getMessage() );
}
return theResult;
}
} //end of class
UNIX Commands
Parser:
try
{
BufferedReader reader = new BufferedRead( new InputStreamReader( new FileInputStream("C:\\TEMP\\data.csv") ) );
String workStr = "";
while( (workStr = reader.readLine()) != null )
{
workStr.trim();
}
catch( FileNotFoundException ex ) {
...... }
Generator:
try {
PrintWrintWriter writer = new PrintWriter( new FileOutputStream( output_filePath ) );
writer.write( outputStringBuffer.toString );
writer.close();
}
catch( IOException ex ) {
......
}
Performance Evaluation:
long startTime = System.currentTimeMillis();
....................
long endTime = System.currentTimeMillis();
System.out.println( "Process time = " + (endTime - startTime) );
GIT Commands:
Create a working copy of a local repository:
$ git clone /path/to/repository
$ git clone username@host:/path/to/repository
Create a new branch:
$ git branch my_new_branch/dev
Create or switch to a new branch:
$ git checkout -b feature/frank
Setup a branch to tract the remote branch 'develop' from 'origin':
$ git branch --set-upstream-to=origin/develop
Commit changes to a branch:
$ git commit -a -m "feature frank OK"
Push all changes to branch:
$ git push origin HEAD
Others:
$ git status
$ git switch origin/frank-dev
$ git pull --rebase