JAVA怎样得到当前程序的路径 RT 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 getProperty("user.dir");不知这个属性名写错没有。? public void testPath() { File f = new File(""); String path = f.getAbsolutePath(); System.out.println(path); }Output:E:\information\personal\workspace\poc\synchrophy\framework 没错System.getProperty("user.dir");可以得到程序的绝对路径 如果程序要打成 jar包的话,就不要用这个了,呵呵 System.out.println(System.getProperty("user.dir") +"\\"+ new TestApplet().getClass().getName()); getAbsolutePath(); //这个可以getProperty("user.dir");//这个没用过 正好学习了 System.getProperty("user.dir"); 学习下这个 马上实验下 JAVA得到当前程序的绝对路径的2种方法 File f = new File("."); //当前pathf.getPath(); System.getProperty("user.dir"); 只能得到Project的路径,不能得到文件路径 String name = Test.class.getCanonicalName().replace(".", "\\");System.out.println(System.getProperty("user.dir") + "\\" + name); System.out.println(System.out.getProperty("uesr.dir"));是得到文件所在的包的路径;System.out.println(this.getClass().getResource().getPath());得到的是文件所在的路径; 【怎么样访问Jar包中的文件?】【新手问题,大家多多帮忙呀】 Stack Overflow,麻烦各位帮忙看看哪里出错了! 简单问题(一个关于验证码的问题) 关于程序运行结果的问题 关于继承抽象类的一个问题,请帮忙。 j2sdk1.4.1_02安装好了,用什么文本编辑器比较好. applet入门问题,帮忙看看! 我JBUILDER编译的APPLET ,生成CLASS后,放在WEB时,竟然是一个红色的“X”,这是什么问题 ? 中国队赢球,特来送分给java的各位兄弟!!!(只限前10名) 插件的实现 appletviewer 问题 软件开发中数据载体的选择问题
{
File f = new File("");
String path = f.getAbsolutePath();
System.out.println(path);
}Output:E:\information\personal\workspace\poc\synchrophy\framework
System.getProperty("user.dir");
可以得到程序的绝对路径
System.out.println(System.getProperty("user.dir") +"\\"+ new TestApplet().getClass().getName());
getProperty("user.dir");//这个没用过 正好学习了
学习下这个 马上实验下
只能得到Project的路径,不能得到文件路径
String name = Test.class.getCanonicalName().replace(".", "\\");
System.out.println(System.getProperty("user.dir") + "\\" + name);
System.out.println(this.getClass().getResource().getPath());得到的是文件所在的路径;