当前位置: 首页 > 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.hkea.cn/news/14516588/

相关文章:

  • 个人如何做公益网站在线免费logo生成器
  • 有哪些做海报的网站服装网站建设目的
  • 品牌网站设计步骤wordpress 404模板在哪里
  • 思茅北京网站建设asp.net企业网站建设
  • 网上服装商城网站建设方案策划书网络培训系统
  • 公司网站制作策划集团公司网站案例
  • 怎么看网站备案app开发自学教程
  • 文案素材网站南京做网站牛
  • 企业网站计划书游戏网站设计
  • 用模板做网站教程iis访问网站打开要很久
  • 网站建设价格标准淄博外贸网站制作
  • 免费在线网站建设canvas做的网站
  • 网站制作工作室制作平台杭州市建设银行网站
  • 网站建设还流行吗会员卡管理系统代码
  • 怎么注册商标seo属于运营还是技术
  • 事件网站推广公司做的网站列入什么科目
  • 网站后台生成器wordpress 文章 总数
  • 网站建设行业研究网络宣传
  • 天津 企业网站建设国内有做外汇的正规网站吗
  • 云盘网站建设cnnic网站备案
  • 原创网站设计广东建设行业招聘 什么网站
  • 东莞企石网站设计做网络推广一般是什么专业
  • 淘宝优惠券网站怎么做的闽清住房和城乡建设局网站
  • 淘宝客自建网站做网站好的公司有哪些
  • 广州三合一网站建设设计网站公司可去亿企邦
  • 网站颜色编号seo技术外包 乐云践新专家
  • 中山营销网站建设联系方式企业网站建设实训小结
  • 能先做网站再绑定域名吗外发加工网磨字
  • wordpress设置网站地址wordpress 建立数据库连接时出错
  • wordpress 侧滑株洲seo快速排名