/**
 * 
 */
package com.qmth.qrzk.repositry.utils.excel;

import java.io.File;
import java.util.regex.Pattern;

public class Util {

    /**
     * get postfix of the path
     * @param path
     * @return
     */
    public static String getPostfix(String path) {
        if (path == null || Common.EMPTY.equals(path.trim())) {
            return Common.EMPTY;
        }
        if (path.contains(Common.POINT)) {
            return path.substring(path.lastIndexOf(Common.POINT) + 1, path.length());
        }
        return Common.EMPTY;
    }
    
    public static boolean isNumeric(String str){ 
        Pattern pattern = Pattern.compile("[0-9]*"); 
        return pattern.matcher(str).matches();    
     }
    
    
  //获取jar绝对路径
  	public static String getJarPath(){
  		File file = getFile();
  		if(file==null)return null;
  		
  		File f=new File(file.getAbsolutePath());
  		 return f.getParent();
  	}
  	//获取jar目录
  	public static String getJarDir() {
  		File file = getFile();
  		if(file==null)return null;
  	     return getFile().getParent();
  	}
  	//获取jar包名
  	public static String getJarName() {
  		File file = getFile();
  		if(file==null)return null;
  		return getFile().getName();
  	}

  	private static File getFile() {
  		//关键是这行...
  		String path = Util.class.getProtectionDomain().getCodeSource().getLocation().getFile();
          try{
              path = java.net.URLDecoder.decode(path, "UTF-8");//转换处理中文及空格
          }catch (java.io.UnsupportedEncodingException e){
              return null;
          }
  		return new File(path);
  	}
  	
  	public static void main(String[] args) {
//  		System.out.println(Util.class.getClass().getResource("MANIFEST.MF"));
//  		System.out.println(Util.class.getResource(""));
//  		System.out.println(Util.class.getResource("/").getFile());
		System.out.println(Util.isNumeric("123"));
	}
}