1 package org.onap.vfc.nfvo.emsdriver.commons.utils;
4 import java.io.FileInputStream;
5 import java.io.FileOutputStream;
6 import java.io.IOException;
7 import java.io.InputStream;
8 import java.io.OutputStream;
9 import java.util.zip.GZIPInputStream;
17 public void unCompress(String gzFileName, String toFile)
19 GZIPInputStream gzIn = null;
20 FileOutputStream fileOutput = null;
21 FileInputStream gzInput = new FileInputStream(gzFileName);
23 gzIn = new GZIPInputStream(gzInput);
24 File tofile = new File(toFile);
26 fileOutput = new FileOutputStream(tofile, false);
28 moveBytes(gzIn, fileOutput, -1, -1, 1024);
33 if(fileOutput != null){
42 private void enable(File tofile) throws IOException {
43 if (!tofile.exists()) {
44 String parentPath = tofile.getParent();
45 if (parentPath != null)
46 new File(parentPath).mkdirs();
47 tofile.createNewFile();
52 public long moveBytes(InputStream input, OutputStream output, long off, long len, int bufsize)
58 byte[] buf = new byte[bufsize];
61 if (len>0 && (len-totalNum)<=0)
64 else if (len>0 && bufsize>(len-totalNum))
65 bufsize = (int)(len-totalNum);
67 int readNum = input.read(buf, 0, bufsize);
71 output.write(buf, 0, readNum);