我有属性文件中的int,float,boolean和string.所有东西都加载了属性.目前,我正在解析值,因为我知道特定键的预期值.
Boolean.parseBoolean("false");
Integer.parseInt("3")
Run Code Online (Sandbox Code Playgroud)
什么是设置这些常量值的更好方法,如果我不知道键的原始值数据类型是什么.
public class Messages {
Properties appProperties = null;
FileInputStream file = null;
public void initialization() throws Exception {
appProperties = new Properties();
try {
loadPropertiesFile();
} catch (Exception e) {
throw new Exception(e.getMessage(), e);
}
}
public void loadPropertiesFile() throws IOException {
String path = "./cfg/message.properties";
file = new FileInputStream(path);
appProperties.load(file);
file.close();
}
}
Run Code Online (Sandbox Code Playgroud)
属性文件.messassge.properties
SSO_URL = https://example.com/connect/token
SSO_API_USERNAME = test
SSO_API_PASSWORD = Uo88YmMpKUp
SSO_API_SCOPE = intraday_api
SSO_IS_PROXY_ENABLED = false
SSO_MAX_RETRY_COUNT = 3
SSO_FLOAT_VALUE = 3.0 …Run Code Online (Sandbox Code Playgroud) 在Java 8中,我看到在Files类中添加了名为lines()的新方法,可用于在Java中逐行读取文件.它适用于大文件吗?我的意思是我们可以加载前1000行然后第二组1000行.我有1GB的巨大文件,它会工作吗?
有人可以共享代码片段如何使用它?
如何在 Windows 中安装 Java JDK 8?
我需要管理员权限吗?
如果我只是将 JDK 从一个系统复制到另一个具有管理员权限的系统,会发生什么。