0
我有一些壓縮字符串(每個1.5M)存儲在一個文件中。我需要讀出它們,並對它們進行一些計算。基本上,這裏是我做過什麼:android:快速方式處理壓縮字符串
public static Object fetchRSFB(File inFile) {
FileInputStream fis = null;
ObjectInputStream ois = null;
GZIPInputStream gs = null;
Object result = null;
try {
fis = new FileInputStream(inFile);
gs = new GZIPInputStream(fis);
ois = new ObjectInputStream(gs);
MyBWT.rankArray = (int[]) ois.readObject();
String str= (String) ois.readObject();
//do something with the string
唯一的問題是,代碼的性能是一般相當緩慢,所以我想2種選擇:
使用NIO來圖將壓縮文件存儲到內存中,並在內存壓縮文件上執行以上操作(聽說這可能是可以實現的,但我不知道它是否真的存在)
而不是存儲對象,我可以將二進制壓縮文本的版本,然後閱讀文本,我聽說它馬然後快速ObjectInputStream。
任何人都知道實現上述選項的方法嗎?或者有更好的方法,非常感謝。