public static String KeyInfo() {
InputStream inputStream = null;
InputStreamReader isr = null;
BufferedReader br = null;
StringBuffer sb = new StringBuffer();
try {
File file = new File(Constants.KEYINFO_PATH);
if (file.exists()) {
inputStream = new FileInputStream(file);
} else {
Log.d("zfr","未读取到文件内容");
return null;
}
//inputStream = assetManager.open("cacert-payplus.ubin.top.pem");
isr = new InputStreamReader(inputStream);
br = new BufferedReader(isr);
sb.append(br.readLine());
String line = null;
while ((line = br.readLine()) != null) {
sb.append("\n" + line);
}
br.close();
isr.close();
inputStream.close();
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
if (br != null) {
br.close();
}
if (isr != null) {
isr.close();
}
if (inputStream != null) {
inputStream.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
//return sb.toString();
keyInfo = sb.toString();
//Log.d("zfr_证书===", sb.toString());
return keyInfo;
}
if (SignUtil.KeyInfo() == null) {
Log.d("zfr", "读取文件失败");
return null;
}
把证书文件放在自己的机器中(目录如下):
public static final String KEYINFO_PATH = FinancialApplication.mApp.getFilesDir() + File.separator + "config.properties";
注:如有问题可以回复,看到第一时间分析解决,码农不易,感觉对您有用,帮助到您,可否打赏一杯可乐,在此谢过诸位,愿诸君终成大神,前程似锦~~~