我有一个项目,我正在其中写入文件对象,然后尝试将保存在filecahce中的文件对象读入LinkedBlockingQueue
下面是我用来打开文件并读取它的功能。但它给出以下异常。请帮助
public static obInputStream getObject(Context context, String fileName) {
ObjectInputStream inputstreamobject= null;
try
{
Log.d(TAG, "Trying to read file: " + fileName);
ois = new ObjectInputStream(context.openFileInput(fileName));
}
catch (FileNotFoundException e)
{
Log.d(TAG, "FileNotFoundException for file: " + fileName);
e.printStackTrace();
}
catch (StreamCorruptedException e)
{
Log.d(TAG, "StreamCorruptedException for file: " + fileName);
e.printStackTrace();
}
catch (IOException e)
{
Log.d(TAG, "IOException for file: " + fileName);
e.printStackTrace();
}
catch ( Exception e)
{
Log.d(TAG, "Exception for file: " + fileName);
e.printStackTrace();
}
return ois;
}
W/System.err: java.io.InvalidClassException: com.sampleproject.SyncClient; no valid constructor
W/System.err: at java.io.ObjectStreamClass$ExceptionInfo.newInvalidClassException(ObjectStreamClass.java:147)
W/System.err: at java.io.ObjectStreamClass.checkDeserialize(ObjectStreamClass.java:757)
W/System.err: at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1773)
W/System.err: at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1351)
W/System.err: at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1992)
W/System.err: at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1916)
W/System.err: at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1799)
W/System.err: at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1351)
W/System.err: at java.io.ObjectInputStream.readObject(ObjectInputStream.java:373)
W/System.err: at java.util.concurrent.LinkedBlockingQueue.readObject(LinkedBlockingQueue.java:980)
W/System.err: at java.lang.reflect.Method.invoke(Native Method)
W/System.err: at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:1006)
W/System.err: at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1894)
W/System.err: at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1799)
W/System.err: at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1351)
W/System.err: at java.io.ObjectInputStream.readObject(ObjectInputStream.java:373)
at com.sampleproject.initOfflineMsgQueue(smpleprjct.java:341)
W/System.err: at com.sampleproject.onCreate(smpleprjct.java:327)
W/System.err: at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1032)
W/System.err: at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5876)
W/System.err: at android.app.ActivityThread.-wrap3(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1699)
W/System.err: at android.os.Handler.dispatchMessage(Handler.java:102)
W/System.err: at android.os.Looper.loop(Looper.java:154)
W/System.err: at android.app.ActivityThread.main(ActivityThread.java:6682)
at java.lang.reflect.Method.invoke(Native Method)
W/System.err: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1520)
W/System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1410)