私は日食で証明書パーサーをプログラミングしていました。私の国の政府部門が提供するクラスを使用して、私の国の特殊な証明書を解析できるようにしました。しかし、私は少し問題があります. コードをコンパイルすると、コンソールに次の情報が表示されます:</p>
java.lang.ClassCastException: java.util.ArrayList cannot be cast to tw.com.chttl.hipki.CredentialBean
at CertParser.Read_Normal(CertParser.java:41)
at CertParser.<init>(CertParser.java:26)
at CertParser.main(CertParser.java:155)
ClassCastException の問題については、強制変換の問題であることがわかっています。しかし、私が使用するクラスは文字列型で、次のようになります:</p>
public String getNonce(){
return _credential.getNonce();
}
また
public String getSubjectDN(){
returnCertParser.getSubjectDN(_credential.getSignerCertificate(0));}
私のコードで考えられるエラー:</p>
private int Read_Normal(JPanel panel){
String Field;
try{
FileInputStream file_inputstream=new FileInputStream(CA_Name);
CertificateFactory cf=CertificateFactory.getInstance("X.509");
CredentialBean bean=(CredentialBean)cf.generateCertificates(file_inputstream);
Field=bean.getSubjectDN();
CA_ItemData[0][0]="getSubjectDN";
CA_ItemData[0][1]=Field;
System.out.println("getSubjectDN:"+Field);
Field=bean.getIssuerDN();
CA_ItemData[1][0]="getIssuerDN";
CA_ItemData[1][1]=Field;
System.out.println("getIssuerDN:"+Field);
file_inputstream.close();
final JTable table = new JTable(CA_ItemData, columnNames);
TableColumn tc=null;
tc = table.getColumnModel().getColumn(1);
tc.setPreferredWidth(600);
panel.add(table);
}catch(Exception exception){
exception.printStackTrace();
return -1;
}
return 0;
}
このクラスはすべて文字列型で、私のコードも文字列です。この問題はどういう意味ですか?
私の英語は私の国では主なものではありません。間違いがあれば、ご容赦ください。
ありがとうございました。