问一个相对路径的写法 InputStream stream = this.getClass().getResourceAsStream("testApp.properties"); 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 new FileInputStream(".\\filename"); new FileInputStream("filename"); 我的程序为,这里按你们用的方法都试过了不行,new FileInputStream("")应该怎样写啊! static{ try { System.getProperties().load(new FileInputStream("")); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } public static void main(String[] args) { System.out.println(System.getProperties().getProperty("var2")); } 改了一下,这样可以了public class ReadProperties { static{ try { ReadProperties a = new ReadProperties(); InputStream stream = a.mm(); System.getProperties().load(stream); } catch (FileNotFoundException e) { // TODO 自动生成 catch 块 e.printStackTrace(); } catch (IOException e) { // TODO 自动生成 catch 块 e.printStackTrace(); } } InputStream mm() { InputStream stream = this.getClass().getResourceAsStream("constants.properties"); return stream; } public static void main(String[] args) { System.out.println(System.getProperties().getProperty("var2")); }} java 中为什么用setBackground()不能设置背景色 代码转换到流 JAVA聊天室问题紧急求助 急,swing中如何根据table列名长短的内容,自动调整列的宽度 用java发送邮件 怎样实现显示发送进度 jfreeChart问题!!! java 并发插入数据到oracle 有个字符串,须对其中的值排序的小问题,在线等 JBuilder7速度为什么这么慢 有 ORACLE 错误码文档吗? 谢谢大家! jdbc连接数据库问题 用jdk实现了一个server端,但为何server端不能接收键盘的输入啊。
static{
try {
System.getProperties().load(new FileInputStream(""));
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
System.out.println(System.getProperties().getProperty("var2"));
}
public class ReadProperties {
static{
try {
ReadProperties a = new ReadProperties();
InputStream stream = a.mm();
System.getProperties().load(stream);
} catch (FileNotFoundException e) {
// TODO 自动生成 catch 块
e.printStackTrace();
} catch (IOException e) {
// TODO 自动生成 catch 块
e.printStackTrace();
}
}
InputStream mm() {
InputStream stream = this.getClass().getResourceAsStream("constants.properties");
return stream;
}
public static void main(String[] args) {
System.out.println(System.getProperties().getProperty("var2"));
}
}