Skip to content

Instantly share code, notes, and snippets.

@pandanote-info
Created August 6, 2018 13:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pandanote-info/a583141ab8b2c2a00832d4a8702ad6e4 to your computer and use it in GitHub Desktop.
Save pandanote-info/a583141ab8b2c2a00832d4a8702ad6e4 to your computer and use it in GitHub Desktop.
Apache SolrのDataImportHandlerに7-zipで圧縮されたファイルを読み込ませるために実装したInputStream。
package info.pandanote.szdi;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import org.apache.commons.compress.archivers.sevenz.SevenZFile;
public class SevenZFileInputStream extends InputStream {
SevenZFile sevenZFile = null;
public SevenZFileInputStream(File file) {
try {
sevenZFile = new SevenZFile(file);
sevenZFile.getNextEntry();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
@Override
public int read() throws IOException {
return sevenZFile.read();
}
public int read(byte[] b) throws IOException {
return sevenZFile.read(b);
}
public int read(byte[] b, int off, int len) throws IOException {
return sevenZFile.read(b,off,len);
}
public void close() throws IOException {
sevenZFile.close();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment