簡體   English   中英

在String path = properties.getProperty(“ PRIVATE”);處獲取null

[英]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

但是在代碼中,我從屬性中得到null。 代碼在這里:

    String path = properties.getProperty("PRIVATE");
    String keystore_password = properties.getProperty("PASSWORD");
    String key_password = properties.getProperty("PASSWORD");`

我得到路徑,keystore_password,key_password為空。 那里有什么錯誤?

您將需要按如下方式加載屬性文件:

Properties properties = new Properties();
properties.load(new FileInputStream(YOUR_PATH));

您必須使用以下命令加載屬性文件:

properties.load(new FileInputStream(PATH));

只需添加=登錄屬性文件,例如:

PUBLIC = C:/Documents and Settings/Administrator/Desktop/public.cer
ROOTCERT = C:/examples/signatures/CACertSigningAuthority.crt
PRIVATE = C:/examples/signatures/private.p12
PASSWORD = 123456

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM