java 获取当前应用程序路径

java




package javaapplication1;

import javax.swing.JOptionPane;

/**

*

* @author Administrator

*/

public class JavaApplication1 {

public static String mystr;

public static String str;

/**

* @param args the command line arguments

*/

public static void main(String[] args) {

// TODO code application logic here

try{

int len;

mystr = java.net.URLDecoder.decode(JavaApplication1.class.getProtectionDomain().getCodeSource().getLocation().getFile().replaceAll("/", "\\\\"),"UTF-8");

len = mystr.length();

str = mystr.substring(1,len);

}catch(java.io.UnsupportedEncodingException e){

mystr = "";

str="";

}

JOptionPane.showMessageDialog(null, str);

}

}

以上是 java 获取当前应用程序路径 的全部内容, 来源链接: utcz.com/z/391563.html

回到顶部