@@ -0,0 +1,2910 @@
+/**%0A * Licensed to the Apache Software Foundation (ASF) under one or more%0A * contributor license agreements.  See the NOTICE file distributed with%0A * this work for additional information regarding copyright ownership.%0A * The ASF licenses this file to You under the Apache License, Version 2.0%0A * (the %22License%22); you may not use this file except in compliance with%0A * the License.  You may obtain a copy of the License at%0A *%0A *     http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0Apackage at.illecker.storm.examples.util;%0A%0Aimport java.io.BufferedInputStream;%0Aimport java.io.BufferedOutputStream;%0Aimport java.io.File;%0Aimport java.io.FileInputStream;%0Aimport java.io.FileNotFoundException;%0Aimport java.io.FileOutputStream;%0Aimport java.io.IOException;%0A%0Aimport org.apache.commons.compress.archivers.tar.TarArchiveEntry;%0Aimport org.apache.commons.compress.archivers.tar.TarArchiveInputStream;%0Aimport org.apache.commons.compress.compressors.gzip.GzipCompressorInputStream;%0Aimport org.slf4j.Logger;%0Aimport org.slf4j.LoggerFactory;%0A%0Apublic class FileUtil %7B%0A  public static final int BUFFER_SIZE = 2048;%0A  private static final Logger LOG = LoggerFactory.getLogger(FileUtil.class);%0A%0A  public static void extractTarGz(String inputTarGz, String outDir)%0A      throws IOException %7B%0A%0A    FileInputStream fin = new FileInputStream(inputTarGz);%0A    BufferedInputStream in = new BufferedInputStream(fin);%0A    GzipCompressorInputStream gzIn = new GzipCompressorInputStream(in);%0A    TarArchiveInputStream tarIn = new TarArchiveInputStream(gzIn);%0A%0A    TarArchiveEntry entry = null;%0A    // read Tar entries%0A    while ((entry = (TarArchiveEntry) tarIn.getNextEntry()) != null) %7B%0A      LOG.info(%22Extracting: %22 + entry.getName());%0A%0A      if (entry.isDirectory()) %7B // create directory%0A        File f = new File(outDir + entry.getName());%0A        f.mkdirs();%0A      %7D else %7B // decompress file%0A        int count;%0A        byte data%5B%5D = new byte%5BBUFFER_SIZE%5D;%0A%0A        FileOutputStream fos = new FileOutputStream(outDir + entry.getName());%0A        BufferedOutputStream dest = new BufferedOutputStream(fos, BUFFER_SIZE);%0A        while ((count = tarIn.read(data, 0, BUFFER_SIZE)) != -1) %7B%0A          dest.write(data, 0, count);%0A        %7D%0A        dest.close();%0A      %7D%0A    %7D%0A    // close input stream%0A    tarIn.close();%0A  %7D%0A%0A  public static void delete(File f) throws IOException %7B%0A    LOG.info(%22Delete: %22 + f.getAbsolutePath());%0A    if (f.isDirectory()) %7B%0A      for (File c : f.listFiles())%0A        delete(c);%0A    %7D%0A    if (!f.delete()) %7B%0A      throw new FileNotFoundException(%22Failed to delete file: %22 + f);%0A    %7D%0A  %7D%0A%7D%0A

Add FileUtil