|
|
|
@ -45,37 +45,46 @@ public class plasmaStore {
|
|
|
|
|
|
|
|
|
|
// some static helper methods
|
|
|
|
|
public static void saveGzip(File f, byte[] content) throws IOException {
|
|
|
|
|
f.getParentFile().mkdirs();
|
|
|
|
|
java.util.zip.GZIPOutputStream gzipout = new java.util.zip.GZIPOutputStream(new FileOutputStream(f));
|
|
|
|
|
gzipout.write(content, 0, content.length);
|
|
|
|
|
gzipout.close();
|
|
|
|
|
java.util.zip.GZIPOutputStream gzipout = null;
|
|
|
|
|
try {
|
|
|
|
|
f.getParentFile().mkdirs();
|
|
|
|
|
gzipout = new java.util.zip.GZIPOutputStream(new FileOutputStream(f));
|
|
|
|
|
gzipout.write(content, 0, content.length);
|
|
|
|
|
} finally {
|
|
|
|
|
if (gzipout!=null)try{gzipout.close();}catch(Exception e){}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static byte[] loadGzip(File f) throws IOException {
|
|
|
|
|
java.util.zip.GZIPInputStream gzipin = new java.util.zip.GZIPInputStream(new FileInputStream(f));
|
|
|
|
|
byte[] result = new byte[1024];
|
|
|
|
|
byte[] buffer = new byte[512];
|
|
|
|
|
byte[] b;
|
|
|
|
|
int len = 0;
|
|
|
|
|
int last;
|
|
|
|
|
while ((last = gzipin.read(buffer, 0, buffer.length)) > 0) {
|
|
|
|
|
// assert the buffer to the result
|
|
|
|
|
while (result.length - len < last) {
|
|
|
|
|
// the result array is too small, increase space
|
|
|
|
|
b = new byte[result.length * 2];
|
|
|
|
|
System.arraycopy(result, 0, b, 0, len);
|
|
|
|
|
result = b; b = null;
|
|
|
|
|
}
|
|
|
|
|
// copy the last read
|
|
|
|
|
System.arraycopy(buffer, 0, result, len, last);
|
|
|
|
|
len += last;
|
|
|
|
|
}
|
|
|
|
|
gzipin.close();
|
|
|
|
|
// finished with reading. now cut the result to the right size
|
|
|
|
|
b = new byte[len];
|
|
|
|
|
System.arraycopy(result, 0, b, 0, len);
|
|
|
|
|
result = null;
|
|
|
|
|
return b;
|
|
|
|
|
java.util.zip.GZIPInputStream gzipin = null;
|
|
|
|
|
try {
|
|
|
|
|
gzipin = new java.util.zip.GZIPInputStream(new FileInputStream(f));
|
|
|
|
|
byte[] result = new byte[1024];
|
|
|
|
|
byte[] buffer = new byte[512];
|
|
|
|
|
byte[] b;
|
|
|
|
|
int len = 0;
|
|
|
|
|
int last;
|
|
|
|
|
while ((last = gzipin.read(buffer, 0, buffer.length)) > 0) {
|
|
|
|
|
// assert the buffer to the result
|
|
|
|
|
while (result.length - len < last) {
|
|
|
|
|
// the result array is too small, increase space
|
|
|
|
|
b = new byte[result.length * 2];
|
|
|
|
|
System.arraycopy(result, 0, b, 0, len);
|
|
|
|
|
result = b; b = null;
|
|
|
|
|
}
|
|
|
|
|
// copy the last read
|
|
|
|
|
System.arraycopy(buffer, 0, result, len, last);
|
|
|
|
|
len += last;
|
|
|
|
|
}
|
|
|
|
|
gzipin.close();
|
|
|
|
|
// finished with reading. now cut the result to the right size
|
|
|
|
|
b = new byte[len];
|
|
|
|
|
System.arraycopy(result, 0, b, 0, len);
|
|
|
|
|
result = null;
|
|
|
|
|
return b;
|
|
|
|
|
} finally {
|
|
|
|
|
if (gzipin != null) try{gzipin.close();}catch(Exception e){}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* public static void saveProperties(File f, Properties props, String comment) throws IOException {
|
|
|
|
|