从本地目录加载resources.properties文件,而不是Java中的JAR,可以通过以下步骤实现:
String filePath = "config/resources.properties";
File file = new File(filePath);
String absolutePath = file.getAbsolutePath();
或者使用Path类:
Path path = Paths.get("config/resources.properties");
String absolutePath = path.toAbsolutePath().toString();
Properties properties = new Properties();
try (InputStream input = new FileInputStream(absolutePath)) {
properties.load(input);
} catch (IOException e) {
e.printStackTrace();
}
String databaseUrl = properties.getProperty("database.url");
这样,你就可以从本地目录加载resources.properties文件,并使用其中的属性值进行后续的操作。
对于腾讯云相关产品和产品介绍链接地址,由于要求不能提及具体的云计算品牌商,无法提供相关链接。但是,腾讯云提供了丰富的云计算服务,包括云服务器、云数据库、云存储等,你可以通过访问腾讯云官方网站或搜索腾讯云相关文档来了解更多信息。
领取专属 10元无门槛券
手把手带您无忧上云