/**
* This method wraps the input stream with the
* corresponding decompression method
*
* @param file provides location information for BuildException
* @param istream input stream
* @return input stream with on-the-fly decompression
* @exception IOException thrown by GZIPInputStream constructor
*/
private InputStream decompress(final File file,
final InputStream istream) throws IOException
{
final String value = getValue();
if (GZIP.equals(value))
{
return new GZIPInputStream(istream);
}
else
{
if (BZIP2.equals(value))
{
final char[] magic = new char[] {'B', 'Z'};
for (int i = 0; i < magic.length; i++)
{
if (istream.read() != magic[i])
{
throw new BuildException("Invalid bz2 file."
+ file.toString());
}
}
return new CBZip2InputStream(istream);
}
}
return istream;
}
}
}
解压tar包工具UntarUtil(4)
最新推荐文章于 2023-01-25 12:44:56 发布