[英]android FileInputStream EOF
I am creating a new File object like so: 我正在创建一个新的File对象,如下所示:
keystoreFile = new File(getDir("sslDir", Context.MODE_PRIVATE), "CAKeyStore.jks")
Later, I try to use the the file for an input stream like so: 稍后,我尝试将文件用于输入流,如下所示:
BufferedInputStream bufstream = new BufferedInputStream(new FileInputStream(keystoreFile));
Log.d(TAG, "Available? " + bufstream.available());
sslKeystore.load(bufstream , KEYSTORE_PASSWORD.toCharArray());
and in logcat I get an EOF Exception, and "available" bytes shown is zero 在logcat中,我得到一个EOF异常,并且显示的“可用”字节为零
Available? 0
07-09 18:00:13.090 11229-11229/de.blinkt.openvpn W/System.err﹕ java.io.EOFException
07-09 18:00:13.090 11229-11229/de.blinkt.openvpn W/System.err﹕ at libcore.io.Streams.readFully(Streams.java:83)
07-09 18:00:13.090 11229-11229/de.blinkt.openvpn W/System.err﹕ at java.io.DataInputStream.readInt(DataInputStream.java:103)
07-09 18:00:13.090 11229-11229/de.blinkt.openvpn W/System.err﹕ at com.android.org.bouncycastle.jcajce.provider.keystore.bc.BcKeyStoreSpi.engineLoad(BcKeyStoreSpi.java:799)
07-09 18:00:13.100 11229-11229/de.blinkt.openvpn W/System.err﹕ at java.security.KeyStore.load(KeyStore.java:589)
However, if I clear my apps data, and try this again, I don't get the problem. 但是,如果我清除了我的应用程序数据,然后再试一次,则不会出现问题。
Is there something wrong with the way I am creating the file, such that when the app is re-loaded I get this EOF exception? 我创建文件的方式有问题,例如,重新加载应用程序时出现此EOF异常吗?
Edit: 编辑:
The method where the file is actually created is within this function: 实际创建文件的方法在此函数内:
private void saveKeystore() {
try {
sslKeystore.store(new FileOutputStream(keystoreFile), KEYSTORE_PASSWORD.toCharArray());
} catch (Exception e) {
Log.d(TAG, "Unable to save keystore");
e.printStackTrace();
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.