How can we write our own code template file in IntelliJ IDEA

Here's the contents of my File Header.java

/**
 * Project: ${PROJECT_NAME}
 * Package: ${PACKAGE_NAME}
 * <p>
 * User: ${USER}
 * Date: ${DATE}
 * Time: ${TIME}
 * <p>
 * Created with IntelliJ IDEA
 * To change this template use File | Settings | File Templates.
 */

First, in IntelliJ, open Settings (ctrl-alt-s), under IDE Settings find File and Code Templates and have a look at the Templates tab.

You will see some templates there already, for example there is one called Class:

#if (${PACKAGE_NAME} && ${PACKAGE_NAME} != "")package ${PACKAGE_NAME};#end
#parse("File Header.java")
public class ${NAME} {
}

Note that it includes File Header, which is found under the Includes tab.

Now, you can easily create your own file templates here. Under the Templates tab, just hit the green "Add" button, give your new template a name (Foo ?),ensure the extension is java and write a valid java class.

Save, and your newly configured template exists here:

C:\Users\{USER}\.IntelliJIdea12\config\fileTemplates\Foo.java

You should be able to share this file with your team.

A neat feature is that from within the Project pane of a java project, under a source root, hit alt-enter, choose a New Java Class and under the Kind drop-down - voila! You can see your Foo template as a valid option.