FIXED - task 616: Support bzip2 decompression on import

http://code.google.com/p/google-refine/issues/detail?id=616

git-svn-id: http://google-refine.googlecode.com/svn/trunk@2568 7d457c2a-affb-35e4-300a-418c747d4874
This commit is contained in:
Tom Morris 2012-09-22 16:00:42 +00:00
parent e483cb432d
commit 748e205ae8

View File

@ -631,9 +631,16 @@ public class ImportingUtilities {
|| "x-gzip".equals(contentEncoding)) {
return new GZIPInputStream(new FileInputStream(file));
} else if (fileName.endsWith(".bz2")) {
return new CBZip2InputStream(new FileInputStream(file));
InputStream is = new FileInputStream(file);
is.mark(4);
if (!(is.read() == 'B' && is.read() == 'Z')) {
// No BZ prefix as appended by command line tools. Reset and hope for the best
is.reset();
}
return new CBZip2InputStream(is);
}
} catch (IOException e) {
logger.warn("Something that looked like a compressed file gave an error on open: "+file,e);
}
return null;
}