当前位置: 首页 > news >正文

长沙网站建设哪里好网页浏览器英文缩写

长沙网站建设哪里好,网页浏览器英文缩写,深圳均安网站制作,做网站好还是做程序员好需求 应公司质量部要求#xff0c;需要对代码做静态检查。质量部要求#xff0c;源码文件必须在起始行起设置一些注释#xff0c;然而项目已经开发了一年之久#xff0c;且没有维护这个注释。 此时#xff0c;面对好几千个源码文件#xff0c;我们如何快速添加相应的注…需求 应公司质量部要求需要对代码做静态检查。质量部要求源码文件必须在起始行起设置一些注释然而项目已经开发了一年之久且没有维护这个注释。 此时面对好几千个源码文件我们如何快速添加相应的注释呢 对自己写一个程序来实现。 分析 假设注释模板为 /** Model: 模块* Description: 描述 * Author: 作者* Finished: 时间*/只要获得 模块 、描述、作者、时间 的值既可以通过文档读写完成给源码添加注释的需求。 代码 根据分析实现代码如下 package com.xzbd.jrx;import java.io.*; import java.nio.charset.Charset; import java.nio.file.*; import java.nio.file.attribute.BasicFileAttributes; import java.time.format.DateTimeFormatter; import java.util.Date; import java.util.List;import cn.hutool.core.date.DateUtil; import cn.hutool.core.util.RuntimeUtil; import cn.hutool.core.util.StrUtil;public class AddFileHeaderComment {private static String projectPath D:\\workspace\\builder_backend;public static void main(String[] args) {addFileHeaderComments(projectPath);}public static void addFileHeaderComments(String projectPath) {try {Files.walkFileTree(Paths.get(projectPath), new SimpleFileVisitorPath() {Overridepublic FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {String filePath file.toString();// 仅对Java文件进行if (filePath.endsWith(.java)) {addCommentToFile(file.toFile());}return FileVisitResult.CONTINUE;}});} catch (IOException e) {e.printStackTrace();}}public static void addCommentToFile(File file) {try {String packageName getPackageName(file);String className getClassName(file);String author getAuthor(file);String date getFileModifiedDate(file);String comment String.format(/*%n * Model: %s%n * Description: %s%n * Author: %s%n * Finished: %s%n */%n%n, packageName, className, author, date);String originalContent Files.readString(file.toPath());String newContent comment originalContent;Files.write(file.toPath(), newContent.getBytes(utf-8));} catch (IOException e) {e.printStackTrace();}}public static String getPackageName(File file) throws IOException {String absolutePath file.getAbsolutePath();String sep com\\xzbd\\;String packageName StrUtil.subAfter(absolutePath, sep, false);packageName StrUtil.subBefore(packageName, File.separator, false);// 可以使用 file.getParent().getFileName(); 根据需要调整return packageName;}public static String getClassName(File file) {return file.getName().replaceFirst([.][^.]$, );}public static String getAuthor(File file) {String absolutePath file.getAbsolutePath();String cmd String.format(git --git-dir%s\\.git --work-tree%s log --reverse %s, projectPath, projectPath,absolutePath);ListString execForLines RuntimeUtil.execForLines(Charset.forName(utf-8), cmd);for (String line : execForLines) {String sep Author:;if (StrUtil.startWith(line, sep)) {String useranme StrUtil.subAfter(line, sep, false);return useranme;}}return Your Name;}public static String getFileModifiedDate(File file) {String absolutePath file.getAbsolutePath();String cmd String.format(git --git-dir%s\\.git --work-tree%s log --reverse %s, projectPath, projectPath,absolutePath);ListString execForLines RuntimeUtil.execForLines(Charset.forName(utf-8), cmd);for (String line : execForLines) {String sep Date:;if (StrUtil.startWith(line, sep)) {String dateStr StrUtil.subAfter(line, sep, false);Date data new Date(dateStr);DateTimeFormatter dateFmt DateTimeFormatter.ofPattern(yyyy年MM月dd日);String date DateUtil.format(data, dateFmt);return date;}}DateTimeFormatter dateFmt DateTimeFormatter.ofPattern(yyyy年MM月dd日);String date DateUtil.format(new Date(), dateFmt);return date;} } 执行后的效果 总结 文中代码程序实现了对java文件添加注释的功能其中用到了 hutool-all 工具其 pom 如下 dependencygroupIdcn.hutool/groupIdartifactIdhutool-all/artifactIdversion5.8.16/version/dependency另外程序也使用了 git log 查看文件的日志信息以获取文件正确的作者和完成时间。该 git 命令详解参考文章【Git】任何位置查看git日志
http://www.dnsts.com.cn/news/199650.html

相关文章:

  • 深圳最好的网站建设公司排名网站建设中国站需求分析报告
  • 洛阳建设信息网站大连seo外包平台
  • 采购需求网站建设一个域名访问不同的网站
  • 什么是网站维护中沈阳教做网站
  • 有没有做高仿手表的网站ios手机网站建设
  • wordpress整站导出网站改版需要多少钱
  • 如何做移动端网站合肥自助建站
  • 做兼职网站制作一个小型网站
  • 微网站如何做微信支付宝支付宝支付宝网页设计怎么赚钱
  • 全屏网站源码宝格丽官网
  • wordpress站点的根目录oa软件有哪些公司
  • 百度如何建网站centos wordpress 2m
  • 网站域名注册管理中心施工企业管理协会
  • 济南网站建设报价临沂360网站建设推广
  • 如何在网站中做公示信息做企业官网需要注意什么
  • 织梦做的网站页面打不开网页制作模板中学
  • 广东商城网站建设公司wordpress置顶精华图标
  • 网站项目案例做it的网站有哪些
  • 政务服务中心 网站建设网站开发大概多久
  • 有没有做任务的网站网站建设 上市公司
  • 网站备案系统验证码出错用ps软件做ppt模板下载网站有哪些内容
  • 域名空间网站怎么做wordpress推荐
  • mooc网站建设网站开发投入产出分析
  • 一家做特卖的网站公司营销策划方案案例
  • 钢材贸易网站建设农产品网站设计方案
  • 网站建设有什么费用wordpress 域名 根目录
  • 网站的栏目有什么名字怎么查看网站外链
  • 昆山建设企业网站旅游网站设计说明
  • 模板生成网站share poine 户做网站
  • 中国航空集团建设开发有限公司网站产品网络营销推广方式