Archive for the ‘Programming Languages’ Category

Smart Java Code Blocks

Read entries in a Map<Key, Value>:

for (Map.Entry entry : entityWeight.entrySet()) {
	System.out.println(entry.getKey() + ":" + entry.getValue());

Open a file and append text to the end of the file:

File file = new File("X:/Spritzer/Daily/" + stringDate + ".txt");
if (!file.exists())
FileWriter fileWritter = new FileWriter(file, true); // append
BufferedWriter bufferWritter = new BufferedWriter(fileWritter);

Obtain designated date format:

Date date = new Date();
SimpleDateFormat dateformat = new SimpleDateFormat("yyyyMMddhhmm");
String stringDate = dateformat.format(date);
Categories: Programming Languages

Text/Image vertically middle-align in a DIV

Define the line height in a DIV as the same height of the DIV:

div{line-height:   20px;
    height:   20px;}

For images, write “vertical-align:middle” in its style then you make it.

Categories: Programming Languages Tags: