Android加载数组字符串数组列表EOF Exception

时间:2013-10-01 14:05:38

标签: java android inputstream serializable eofexception

我在我的应用程序中使用ObjectInputStream加载一个ArrayList。奇怪的是,它似乎直到最近一直很好。我看不出是什么导致了它。

以下是涉及的代码片段:

protected ArrayList<String[]> LoadDetailList() {
    InputStream breedin;
    ArrayList<String[]> list = null;
    try {
        breedin = openFileInput("DetailList.ser");
        list = SaveAndLoad.doLoadDetailList(breedin);
    } catch (FileNotFoundException e) {
        System.out.println("Details List not found");
        list = new ArrayList<String[]>();
    }
    Stored.addAllDetails(list);
    return list;
}

@SuppressWarnings("unchecked")
public static ArrayList<String[]> doLoadDetailList(InputStream breedin) {
    ArrayList<String[]> h = null;

    try {

        ObjectInputStream in = new ObjectInputStream(breedin);

        h = (ArrayList<String[]>) in.readObject();

        in.close();
        breedin.close();

    } catch (ClassNotFoundException e) {
        e.printStackTrace();
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }

    return h;
}

例外:

10-01 14:58:07.130: W/System.err(23213): java.io.EOFException
10-01 14:58:07.130: W/System.err(23213):    at java.io.DataInputStream.readByte(DataInputStream.java:98)
10-01 14:58:07.130: W/System.err(23213):    at java.io.ObjectInputStream.nextTC(ObjectInputStream.java:506)
10-01 14:58:07.130: W/System.err(23213):    at java.io.ObjectInputStream.readNonPrimitiveContent(ObjectInputStream.java:778)
10-01 14:58:07.130: W/System.err(23213):    at java.io.ObjectInputStream.readObject(ObjectInputStream.java:2003)
10-01 14:58:07.135: W/System.err(23213):    at java.io.ObjectInputStream.readObject(ObjectInputStream.java:1960)
10-01 14:58:07.135: W/System.err(23213):    at java.io.ObjectInputStream.readNewArray(ObjectInputStream.java:1512)
10-01 14:58:07.135: W/System.err(23213):    at java.io.ObjectInputStream.readNonPrimitiveContent(ObjectInputStream.java:785)
10-01 14:58:07.135: W/System.err(23213):    at java.io.ObjectInputStream.readObject(ObjectInputStream.java:2003)
10-01 14:58:07.135: W/System.err(23213):    at java.io.ObjectInputStream.readObject(ObjectInputStream.java:1960)
10-01 14:58:07.135: W/System.err(23213):    at java.util.ArrayList.readObject(ArrayList.java:657)
10-01 14:58:07.135: W/System.err(23213):    at java.lang.reflect.Method.invokeNative(Native Method)
10-01 14:58:07.135: W/System.err(23213):    at java.lang.reflect.Method.invoke(Method.java:511)
10-01 14:58:07.135: W/System.err(23213):    at java.io.ObjectInputStream.readObjectForClass(ObjectInputStream.java:1354)
10-01 14:58:07.135: W/System.err(23213):    at java.io.ObjectInputStream.readHierarchy(ObjectInputStream.java:1266)
10-01 14:58:07.135: W/System.err(23213):    at java.io.ObjectInputStream.readNewObject(ObjectInputStream.java:1855)
10-01 14:58:07.135: W/System.err(23213):    at java.io.ObjectInputStream.readNonPrimitiveContent(ObjectInputStream.java:787)
10-01 14:58:07.135: W/System.err(23213):    at java.io.ObjectInputStream.readObject(ObjectInputStream.java:2003)
10-01 14:58:07.135: W/System.err(23213):    at java.io.ObjectInputStream.readObject(ObjectInputStream.java:1960)
10-01 14:58:07.140: W/System.err(23213):    at admin.SaveAndLoad.doLoadDetailList(SaveAndLoad.java:309)
10-01 14:58:07.140: W/System.err(23213):    at services.server.SendService.LoadDetailList(SendService.java:406)
10-01 14:58:07.140: W/System.err(23213):    at services.server.SendService.getHolding(SendService.java:316)
10-01 14:58:07.140: W/System.err(23213):    at services.server.SendService.processResponse(SendService.java:152)
10-01 14:58:07.140: W/System.err(23213):    at services.server.SendService.sendMessage(SendService.java:128)
10-01 14:58:07.140: W/System.err(23213):    at services.server.SendService$1.run(SendService.java:71)
10-01 14:58:07.140: W/System.err(23213):    at services.server.SendService.startThread(SendService.java:93)
10-01 14:58:07.140: W/System.err(23213):    at services.server.SendService.onHandleIntent(SendService.java:49)
10-01 14:58:07.140: W/System.err(23213):    at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:65)
10-01 14:58:07.140: W/System.err(23213):    at android.os.Handler.dispatchMessage(Handler.java:99)
10-01 14:58:07.140: W/System.err(23213):    at android.os.Looper.loop(Looper.java:137)
10-01 14:58:07.140: W/System.err(23213):    at android.os.HandlerThread.run(HandlerThread.java:60)

任何想法我做错了什么?

感谢。

0 个答案:

没有答案