Search code examples
intellij-idea

How to include file header to all the java classes and interfaces which has already created in IntelliJIdea


I have created the file header after adding around 30-40 java classes and interfaces , is there any method to include that header tag to all the files which have already created on intelliJIdea , Header tags are being included to all the files which create after defining the header tags on the setting , but how to add them to old files ?


Solution

  • There two different kinds of file header:

    1. File and code templates

    The header file template cannot be applied after file creation, because the template defines the complete file. IntelliJ cannot simply detect what to change after the file has been created.

    If you used this feature to customize your files, I would suggest, that you use the search and replace with regular expression feature.

    2. Copyright

    The purpose of this feature is to provide every file with a copyright/license header.

    The Copyright file header can be adjusted after files have bean created. Follow the instructions and use the update copyright feature.

    Furthermore, IntelliJ has a feature called update copyright that allows you to define a regex to detect copyrights in comments. That enables InelliJ to detect a copyright - or file header in your situation - to apply changes after files have been created.