2011-08-13 39 views
0

我正在使用InputSource來分析大型xml文件(1.2 mb)。我需要將此InputSource保存在內存中。我不想繼續加載它。爲什麼要這樣做最好?我嘗試過使用單例,但Sax Parser抱怨文檔在第二次訪問對象引用後缺少結束標記。在應用程序生命週期中重用InputSource

任何建議將不勝感激。

InputStream ins = getResources().openRawResource(R.raw.cfr_title_index);  
InputSource xmlSource = new InputSource(ins); 
MySinglton.xmlInput = xmlSource; 

感謝

回答

0

流是 「讀一次」。你不應該打算堅持下去。如果你在內存中需要它的內容,把它們讀入一個對象或數據結構並緩存它。

相關問題