Tôi cố gắng để đọc một tập tin .properties và có mã như sau:Nơi đặt tệp thuộc tính?
public final class Config {
static {
Properties properties = new Properties();
InputStream propertiesStream = Object.class.getResourceAsStream("config.properties");
if (propertiesStream != null) {
try {
properties.load(propertiesStream);
} catch (IOException e) {
e.printStackTrace();
}
} else {
System.out.println("file not found");
}
}
}
nhưng nó giữ tập tin không tìm thấy nói.
Nội dung của thuộc tính là
pwd=passw0rd
Bất cứ ai cũng biết làm thế nào để giải quyết vấn đề này?
nếu khuôn khổ bạn đang sử dụng là mùa xuân, thì đây sẽ làm việc tốt –