该计划正在提供FileNotFoundException
。我试图找到它但无法解决它。
例外是:
java.io.FileNotFoundException: src\ritikakeystore (The system cannot find the path specified)
at java.io.FileInputStream.open0(Native Method)
at java.io.FileInputStream.open(Unknown Source)
at java.io.FileInputStream.<init>(Unknown Source)
at java.io.FileInputStream.<init>(Unknown Source)
at packdigit.DigiCert.writing(DigiCert.java:131)
代码如下:
public class DigiCert {
public static final String KEYSTORE = "src/ritikakeystore";
public static final char[] PASSWORD = "ritika".toCharArray();
public static final String SRC = "resources/stw.pdf";
public static final String DEST = "resources/s1new.pdf";
public static final String DEST1 ="resources/s2new.pdf";
public void writing() throws GeneralSecurityException, IOException, DocumentException
{
BouncyCastleProvider provider = new BouncyCastleProvider();
Security.addProvider(provider);
KeyStore ks = KeyStore.getInstance(KeyStore.getDefaultType());
//This statement is showing file Not found error..
ks.load(new FileInputStream(KEYSTORE), PASSWORD);
String alias = (String)ks.aliases().nextElement();
PrivateKey pk = (PrivateKey) ks.getKey(alias, PASSWORD);
Certificate[] chain = ks.getCertificateChain(alias);
DigiCert app = new DigiCert();
app.sign(SRC, DEST, chain, pk, DigestAlgorithms.SHA256,provider.getName(), CryptoStandard.CMS,"First Signature", "Delhi",PdfSignatureAppearance.CERTIFIED_NO_CHANGES_ALLOWED);
app.signAgain(DEST, DEST1, chain, pk, DigestAlgorithms.SHA256,provider.getName(), CryptoStandard.CMS, "Second Signature", "Delhi");
}
文件位置
Src
packdigit(package)
DigiCert.java (class)
ritikakeystore
答案 0 :(得分:0)
如果目录名为Src
,则替换
public static final String KEYSTORE = "src/ritikakeystore";
与
public static final String KEYSTORE = "Src/ritikakeystore";
即Src
到src
,可能会成功。