在 String path= properties.getProperty("PRIVATE") 获取空值;
Get null at String path= properties.getProperty("PRIVATE");
这是我的代码。我正在尝试使用数字签名电子令牌对 pdf 进行签名。
public static String PATH = "C:/Documents and Settings/Administrator/Desktop/New.properties";
/** Some properties used when signing. */
public static Properties properties = new Properties();
New.properties 文件是:
PUBLIC C:/Documents and Settings/Administrator/Desktop/public.cer
ROOTCERT c:/examples/signatures/CACertSigningAuthority.crt
PRIVATE c:/examples/signatures/private.p12
PASSWORD 123456
但是在代码中我从 properties 中得到了 null。
代码在这里:
String path = properties.getProperty("PRIVATE");
String keystore_password = properties.getProperty("PASSWORD");
String key_password = properties.getProperty("PASSWORD");`
我得到路径,keystore_password,key_password 为空。
那里有什么错误?
您必须使用以下方法加载 属性 文件:
properties.load(new FileInputStream(PATH));
您需要按如下方式加载属性文件:-
Properties properties = new Properties();
properties.load(new FileInputStream(YOUR_PATH));
只需添加 =
登录 属性 文件,例如:-
PUBLIC = C:/Documents and Settings/Administrator/Desktop/public.cer
ROOTCERT = C:/examples/signatures/CACertSigningAuthority.crt
PRIVATE = C:/examples/signatures/private.p12
PASSWORD = 123456
这是我的代码。我正在尝试使用数字签名电子令牌对 pdf 进行签名。
public static String PATH = "C:/Documents and Settings/Administrator/Desktop/New.properties";
/** Some properties used when signing. */
public static Properties properties = new Properties();
New.properties 文件是:
PUBLIC C:/Documents and Settings/Administrator/Desktop/public.cer
ROOTCERT c:/examples/signatures/CACertSigningAuthority.crt
PRIVATE c:/examples/signatures/private.p12
PASSWORD 123456
但是在代码中我从 properties 中得到了 null。 代码在这里:
String path = properties.getProperty("PRIVATE");
String keystore_password = properties.getProperty("PASSWORD");
String key_password = properties.getProperty("PASSWORD");`
我得到路径,keystore_password,key_password 为空。 那里有什么错误?
您必须使用以下方法加载 属性 文件:
properties.load(new FileInputStream(PATH));
您需要按如下方式加载属性文件:-
Properties properties = new Properties();
properties.load(new FileInputStream(YOUR_PATH));
只需添加 =
登录 属性 文件,例如:-
PUBLIC = C:/Documents and Settings/Administrator/Desktop/public.cer
ROOTCERT = C:/examples/signatures/CACertSigningAuthority.crt
PRIVATE = C:/examples/signatures/private.p12
PASSWORD = 123456