package com.cs.test.springboot;import java.io.File;import java.io.FileWriter;import java.io.RandomAccessFile;import java.util.ArrayList;import java.util.List;/**
* 批量给项目的java文件添加licence文件头
* <p>
*
* ---1.使用步骤---
* 1.修改projectPath项目路径
* 2.修改licence文件信(编辑好的文本直接复制过来)
* 3.执行main方法
*
*
* ---2.注意事项---
* 如果已经有同样的licence,多次执行,内容相同的不会替换,所以有新增的文件也可以再次执行
* </p>
*/publicclassTest{
/**
* 项目根目录
*/privatestatic String projectPath ="E:\\project\\cslc-admin";/**
* java文件头部的的License文本
*/privatestatic String licence ="/*\n"+"*MIT License\n"+"*\n"+"*Copyright (c) 2019 chenshuai cs4380@163.com\n"+"*\n"+"*Permission is hereby granted, free of charge, to any person obtaining a copy\n"+"*of this software and associated documentation files (the \"Software\"), to deal\n"+"*in the Software without restriction, including without limitation the rights\n"+"*to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n"+"*copies of the Software, and to permit persons to whom the Software is\n"+"*furnished to do so, subject to the following conditions:\n"+"*\n"+"*The above copyright notice and this permission notice shall be included in all\n"+"*copies or substantial portions of the Software.\n"+"*\n"+"*THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n"+"*IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n"+"*FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n"+"*AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n"+"*LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n"+"*OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n"+"*SOFTWARE.\n"+"*/";/**
* 文件处理异常记录
*/privatestatic List<String> fail =newArrayList<>();/**
* JAVA文件关键字内容错误记录
*/privatestatic List<String> wrong =