赞
踩
RunningServiceInfo serviceInfo;//...此处省略n段代码String[] names = serviceInfo.service.getClassName().split("\\.");int length = names.length;String serviceName = names[length - 1];//...此处省略n段代码
public class NameTest { //测试通过 public String getServiceName(String className){ String tempName = className; int indexOfCurr = 0; while(true){ indexOfCurr = tempName.indexOf('.'); if(indexOfCurr == -1){ break; } tempName = tempName.substring(indexOfCurr + 1, tempName.length()); } return tempName; } public static void main(String[] args) { String name = new NameTest().getServiceName("com.xxj.ClassName"); System.out.println(name); }}
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。