Home > Programming Languages > Smart Java Code Blocks

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
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: