zoukankan      html  css  js  c++  java
  • 常用辅助类

    public class ClassHelper {
    
    	/**
    	 * 获取当前正在执行的方法名
    	 * 
    	 * @return
    	 */
    	public static String getCurrentThreadMethodName() {
    		StackTraceElement[] stack = Thread.currentThread().getStackTrace();
    		StackTraceElement stackTraceElement = stack[2];
    		String className = stackTraceElement.getClassName();
    		String methodName = stackTraceElement.getMethodName();
    		String s = className + "." + methodName;
    		return s;
    	}
    
    	/**
    	 * 获取类路径
    	 * 
    	 * @return
    	 */
    	public static String getClassPath() {
    		String path = Thread.currentThread().getContextClassLoader().getResource("").getPath();
    		return path.replace("\", "/");
    	}
    
    	/**
    	 * 获取当前应用的根目录,不含最后的斜线
    	 * 
    	 * @return
    	 */
    	public static String getBasePath() {
    		String classPath = getClassPath();
    		int webInfoIndex = classPath.indexOf("/WEB-INF");
    		if (webInfoIndex > -1) {
    			return classPath.substring(0, webInfoIndex);
    		} else {
    			return classPath.substring(0, classPath.indexOf("/target/classes"));
    		}
    	}
    
    	/**
    	 * 获取当前应用的名字
    	 * 
    	 * @return
    	 */
    	public static String getAppName() {
    		String basePath = getBasePath();
    		int index = basePath.lastIndexOf("/") + 1;
    		return getBasePath().substring(index);
    	}
    }
    

      

  • 相关阅读:
    TensorFlow神经网络集成方案
    过滤节点
    获取子节点
    获取兄弟节点
    获取父节点
    遍历DOM树
    获取修改CSS
    获取修改元素属性
    获取修改value
    获取更新元素文本html()
  • 原文地址:https://www.cnblogs.com/swtjavaspace/p/9837790.html
Copyright © 2011-2022 走看看