当前位置:首页 » 《关注互联网》 » 正文

【Android】去除代码中的注释_m0_62273336的博客

14 人参与  2022年01月19日 10:35  分类 : 《关注互联网》  评论

点击全文阅读


【Android】去除代码中的注释

为您的代码删除/清除所有注释

public static String commentDelete(String code)
{
String result = “”;
boolean string = false;//字符串状态
boolean comment = false;
boolean comment2 = false;
String comments = “”;
boolean comments2 = false;
for (String chars : code.split(""))
{
if (!string && chars.equals(""") && !(comment || comment2 || comments2)) {
string = true;
} else if (string && chars.equals(""") && !(comment || comment2 || comments2) )
{
string = false;
}
else if (string)
{
}
if (!string)
{
if (comment && chars.equals("/"))
{
//是注释
if (comment)
{
comment2 = true;
}
else if (comment && chars.equals(""))
{
comments2 = true;
}
}
else if (!comment && !comment2 && chars.equals("/"))
{
comment = true;//可能是注释,开始判断吧
}
else if ((comment && comment2) && chars.equals("\n"))
{
comment = false;
comment2 = false;
}
else if(comments2 && chars.equals("
"))
{
comments = chars;
}
else if(!(comments.equalsIgnoreCase("*")) && comment2 && chars.equals("/"))
{
comments = “”;
comments2 = false;
} if (!comment)
{
result = result + chars;
}
}
else
{
result = result + chars;
}
}
return result;
}

姚赞丰原创,转载请标明出处


点击全文阅读


本文链接:http://m.zhangshiyu.com/post/33527.html

注释  丰原  您的  
<< 上一篇 下一篇 >>

  • 评论(0)
  • 赞助本站

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

最新文章

  • 山海不相逢内容精选(温逸尘沈衿)_山海不相逢内容精选(温逸尘沈衿)
  • (番外)+(全书)霍沉洲沈青禾此去经年人未还(霍沉洲沈青禾)_(霍沉洲沈青禾此去经年人未还)列表_笔趣阁(霍沉洲沈青禾)
  • (番外)+(全书)霍沉洲沈青禾(此去经年人未还霍沉洲沈青禾)完结_(霍沉洲沈青禾)列表_笔趣阁(此去经年人未还霍沉洲沈青禾)
  • 「重回八零,拒绝替嫁冲喜」章节彩蛋限时释出‌_卫东玉兰苏夏人气小说未删减节选
  • 重生七零祁同伟不再是农民儿子结局+番外纯净版全书免费重生七零祁同伟不再是农民儿子结局+番外纯净版全书免费
  • 傅雅宁的神女老婆,却在背地承欢作乐顾尘傅雅宁全书在线
  • 全文神女老婆,却在背地承欢作乐全局(顾尘傅雅宁)列表_全文神女老婆,却在背地承欢作乐全局
  • (番外)+(全书)此去经年人未还全书+番外+后续免费下载_(沈青禾霍沉洲)此去经年人未还全书+番外+后续列表_笔趣阁(沈青禾霍沉洲)
  • 完结文毁容的姐姐和瞎眼的我离开后,姜家两兄弟悔哭了+后续列表_完结文毁容的姐姐和瞎眼的我离开后,姜家两兄弟悔哭了+后续(林梦婉)
  • 妻子辱我爸受贿自杀,我掏出一等军功章节选推荐_[陈素云辰朋友]小说精彩章节分享
  • 全书浏览苔藓爬满旧日诺言新上(顾砚廷慕晚夏)_苔藓爬满旧日诺言新上(顾砚廷慕晚夏)全书结局
  • 顾尘傅雅宁(神女老婆,却在背地承欢作乐+后续+结局)结局_(顾尘傅雅宁神女老婆,却在背地承欢作乐+后续+结局全书结局)结局列表_笔趣阁(顾尘傅雅宁)

    关于我们 | 我要投稿 | 免责申明

    Copyright © 2020-2022 ZhangShiYu.com Rights Reserved.豫ICP备2022013469号-1