I have a number of compressed String(1.5M each) stored in a file. I need to read them out, and do some computation on them. Basically, here is what I did:
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
The only problem i开发者_StackOverflow中文版s, the performance of the code is quite slow in general, so I am thinking 2 options:
to use NIO to map the compressed file into memory, and do the above on the memory compressed file(I heard that this may be achievable, but I have no idea if it really is)
Instead of storing objects, I could just store binary compressed version of the text and then read the text, I heard that it may be fast then ObjectInputStream.
Anyone knows a way of achieving the above options? or is there a better way, thanks a lot.
You might be interested in using DeflatorOutputStream and InflatorInputStream
see Fast compression in Java?
精彩评论