求java解析tar.Z? 另附上java对zip、tar.gz、 tar.bz、 tar的解压。

       使用java代码解tar.Z文件,程序最终跑在windows上面,不排除以后客户迁移,所以不能使用java调用系统命令的方式解压,只能通过代码来解压。java内部支持解压格式太少,后来使用apache.commons.compress解压了zip、tar.gz、 tar.bz、 tar。但是还是没有找到tar.Z怎么解压,求教高手,帮忙解答。下面是zip、tar.gz、 tar.bz、 tar几种格式的解压。       

 

public List<String> list(InputStream inputStream, boolean isCloseStream) throws IOException {
        List<String> list = new ArrayList<String>();
        ArchiveInputStream in = null;
        try {
            in = new ArchiveStreamFactory().createArchiveInputStream("tar", new BufferedInputStream(inputStream));
            TarArchiveEntry entry = null;
            while ((entry = (TarArchiveEntry) in.getNextEntry()) != null) {
                list.addAll(FileFach.parserEveryFile(entry.getName().replaceAll("\\\\", "/"), in));
            }
        } catch (ArchiveException e) {
            throw new ExtractorException(ErrorType.UNSUPPORTED_FILE_TYPE, e);
        } finally {
            if (isCloseStream) {
                IOUtils.closeQuietly(in);
                IOUtils.closeQuietly(inputStream);
            }
        }
        return list;
    }

 

public List<String> list(InputStream inputStream, boolean isCloseStream) throws IOException {
        List<String> list = new ArrayList<String>();
        ArchiveInputStream in = null;
        GZIPInputStream gis = null;
        try {
            gis = new GZIPInputStream(new BufferedInputStream(inputStream));
            in = new ArchiveStreamFactory().createArchiveInputStream("tar", gis);            
            TarArchiveEntry entry = null;

            while ((entry = (TarArchiveEntry) in.getNextEntry()) != null) {
                list.addAll(FileFach.parserEveryFile(entry.getName().replaceAll("\\\\", "/"), in));
            }
            entry = null;
        } catch (ArchiveException e) {
            throw new ExtractorException(ErrorType.UNSUPPORTED_FILE_TYPE, e);
        } finally {
            if (isCloseStream) {
                IOUtils.closeQuietly(gis);
                IOUtils.closeQuietly(inputStream);
                IOUtils.closeQuietly(in);
            }
        }
        return list;
    }

 

public List<String> list(InputStream inputStream, boolean isCloseStream) throws IOException {

        List<String> list = new ArrayList<String>();
        ArchiveInputStream in = null;
        try {
            in = new ArchiveStreamFactory().createArchiveInputStream("tar", new BZip2CompressorInputStream(inputStream));
            TarArchiveEntry entry = null;
            while ((entry = (TarArchiveEntry) in.getNextEntry()) != null) {
                list.addAll(FileFach.parserEveryFile(entry.getName().replaceAll("\\\\", "/"), in));
            }
        } catch (ArchiveException e) {
            throw new ExtractorException(ErrorType.UNSUPPORTED_FILE_TYPE, e);
        } finally {
            if (isCloseStream) {
                IOUtils.closeQuietly(in);
                IOUtils.closeQuietly(inputStream);
            }
        }
        return list;
    }

 

public List<String> list(InputStream inputStream, boolean isCloseStream) throws IOException {
        List<String> list = new ArrayList<String>();
        ArchiveInputStream in = null;
        try {
            in = new ArchiveStreamFactory().createArchiveInputStream("zip", new BufferedInputStream(inputStream));
            ZipArchiveEntry entry = null;
            while ((entry = (ZipArchiveEntry) in.getNextEntry()) != null) {
                list.addAll(FileFach.parserEveryFile(entry.getName().replaceAll("\\\\", "/"), in));
            }
        } catch (ArchiveException e) {
            throw new ExtractorException(ErrorType.UNSUPPORTED_FILE_TYPE, e);
        } finally {
            if (isCloseStream) {
                IOUtils.closeQuietly(inputStream);
                IOUtils.closeQuietly(in);
            }
        }
        return list;
    }

 

1
[url]http://download.csdn.net/detail/xuxiaoliang/4466030[/url]

2
[url]http://www.example-code.com/java/untar_Z.asp[/url]