Here you can find the source of createHeader(Path newFile)
public static void createHeader(Path newFile)
//package com.java2s; //License from project: LGPL import java.io.BufferedWriter; import java.io.IOException; import java.nio.charset.Charset; import java.nio.file.Files; import java.nio.file.OpenOption; import java.nio.file.Path; import java.nio.file.StandardOpenOption; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; public class Main { public static void createHeader(Path newFile) { //Writing to file try (BufferedWriter writer = Files.newBufferedWriter(newFile, Charset.defaultCharset(), new OpenOption[] { StandardOpenOption.APPEND })) { Date date = new Date(); Calendar cal1 = Calendar.getInstance(); cal1.setTimeInMillis(System.currentTimeMillis()); SimpleDateFormat dateFormat = new SimpleDateFormat("dd-MM-hh:mm:ss"); String sDate = dateFormat.format(cal1.getTime()); String developer = System.getProperty("user.name"); writer.append("*********************************************\n"); writer.append("**** PROJECTSWG PACKET LOG " + sDate + " ***\n"); writer.append("*********************************************\n"); writer.append("DEV: " + developer + "\n"); writer.append("\n"); writer.flush();//from w ww . ja v a2 s .co m } catch (IOException exception) { System.out.println("Error writing to file"); } } }