您好,欢迎来到华佗小知识。
搜索
您的当前位置:首页【Android】去除代码中的注释

【Android】去除代码中的注释

来源:华佗小知识

【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 &

因篇幅问题不能全部显示,请点此查看更多更全内容

Copyright © 2019- huatuo0.cn 版权所有 湘ICP备2023017654号-2

违法及侵权请联系:TEL:199 18 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务