January 10 2017

Java BufferedWriter Example

Java BufferedWriter Example

BufferedWriter class writes text to a character-output stream, buffering characters and provides efficient writing of single characters, arrays, and strings. Compared to FileWriter, BufferedWriter writes relatively large amount of data to a file at once. The buffer size may be specified, or the default size may be used.

BufferedWriter provides a newLine() method to create platform-specific line separators automatically. Wrap the BufferedWriter around a FileWriter, to get access to high level methods.

Key methods: close(), flush(), newLine(), write()

Example Continue reading

August 17 2016

Java calendar last day of month

Java calendar last day of month

Following are the different ways to get last day of the month

  • Set the Calendar object to be in the month for which you need the last date, getActualMaximum(Calendar.DAY_OF_MONTH) will give you the last date of that month.
  • Setting the calendar to the first of next month and subtract a day.

calendar.get(Calendar.DAY_OF_WEEK) returns int values from 1 to 7(1-Sunday and 7-Saturday)

Example Continue reading