本文整理了Java中com.jcraft.jzlib.GZIPInputStream.<init>()
方法的一些代码示例,展示了GZIPInputStream.<init>()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。GZIPInputStream.<init>()
方法的具体详情如下:
包路径:com.jcraft.jzlib.GZIPInputStream
类名称:GZIPInputStream
方法名:<init>
暂无
代码示例来源:origin: jenkinsci/jenkins
/**
* Reads the contents of a file.
*/
public InputStream read() throws IOException {
if(file.exists())
try {
return Files.newInputStream(file.toPath());
} catch (InvalidPathException e) {
throw new IOException(e);
}
// check if the compressed file exists
if(gz.exists())
try {
return new GZIPInputStream(Files.newInputStream(gz.toPath()));
} catch (InvalidPathException e) {
throw new IOException(e);
}
// no such file
throw new FileNotFoundException(file.getName());
}
代码示例来源:origin: jenkinsci/jenkins
/**
* Returns an input stream that reads from the log file.
* It will use a gzip-compressed log file (log.gz) if that exists.
*
* @throws IOException
* @return An input stream from the log file.
* If the log file does not exist, the error message will be returned to the output.
* @since 1.349
*/
public @Nonnull InputStream getLogInputStream() throws IOException {
File logFile = getLogFile();
if (logFile.exists() ) {
// Checking if a ".gz" file was return
try {
InputStream fis = Files.newInputStream(logFile.toPath());
if (logFile.getName().endsWith(".gz")) {
return new GZIPInputStream(fis);
} else {
return fis;
}
} catch (InvalidPathException e) {
throw new IOException(e);
}
}
String message = "No such file: " + logFile;
return new ByteArrayInputStream(charset != null ? message.getBytes(charset) : message.getBytes());
}
代码示例来源:origin: jenkinsci/jenkins
private ConsoleAnnotator<T> createAnnotator(StaplerRequest req) throws IOException {
try {
String base64 = req!=null ? req.getHeader("X-ConsoleAnnotator") : null;
if (base64!=null) {
Cipher sym = PASSING_ANNOTATOR.decrypt();
ObjectInputStream ois = new ObjectInputStreamEx(new GZIPInputStream(
new CipherInputStream(new ByteArrayInputStream(Base64.decode(base64.toCharArray())),sym)),
Jenkins.getInstance().pluginManager.uberClassLoader);
try {
long timestamp = ois.readLong();
if (TimeUnit.HOURS.toMillis(1) > abs(System.currentTimeMillis()-timestamp))
// don't deserialize something too old to prevent a replay attack
return (ConsoleAnnotator)ois.readObject();
} finally {
ois.close();
}
}
} catch (ClassNotFoundException e) {
throw new IOException(e);
}
// start from scratch
return ConsoleAnnotator.initial(context);
}
代码示例来源:origin: jenkinsci/jenkins
public InputStream extract(InputStream _in) throws IOException {
HeadBufferingStream in = new HeadBufferingStream(_in,SIDE_BUFFER_SIZE);
try {
return new GZIPInputStream(in, 8192, true);
} catch (IOException e) {
// various people reported "java.io.IOException: Not in GZIP format" here, so diagnose this problem better
in.fillSide();
throw new IOException(e.getMessage()+"\nstream="+Util.toHexString(in.getSideBuffer()),e);
}
}
public OutputStream compress(OutputStream out) throws IOException {
代码示例来源:origin: jenkinsci/jenkins
try (ObjectInputStream ois = new ObjectInputStreamEx(new GZIPInputStream(new ByteArrayInputStream(buf)),
jenkins != null ? jenkins.pluginManager.uberClassLoader : ConsoleNote.class.getClassLoader(),
ClassFilter.DEFAULT)) {
代码示例来源:origin: stapler/stapler
public GzipAwareSession(File file) throws IOException {
this.gz = new GZIPInputStream(Files.newInputStream(file.toPath(), StandardOpenOption.READ));
}
代码示例来源:origin: org.kohsuke.stapler/stapler
public GzipAwareSession(File file) throws IOException {
this.gz = new GZIPInputStream(Files.newInputStream(file.toPath(), StandardOpenOption.READ));
}
代码示例来源:origin: jenkinsci/docker-build-step-plugin
public InputStream getLogInputStream() throws IOException {
File logFile = getLogFile();
if (logFile != null && logFile.exists()) {
// Checking if a ".gz" file was return
FileInputStream fis = new FileInputStream(logFile);
if (logFile.getName().endsWith(".gz")) {
return new GZIPInputStream(fis);
} else {
return fis;
}
}
String message = "No such file: " + logFile;
return new ByteArrayInputStream(message.getBytes(Charsets.UTF_8));
}
代码示例来源:origin: jerlang/jerlang
public static byte[] maybe_decompress(byte[] bytes) {
if (bytes.length == 0) {
return bytes;
}
if (bytes[0] != 0x1f) {
return bytes;
}
try {
InputStream in = new GZIPInputStream(new ByteArrayInputStream(bytes));
ByteArrayOutputStream out = new ByteArrayOutputStream();
int symbol;
while ((symbol = in.read()) != -1) {
out.write(symbol);
}
in.close();
bytes = out.toByteArray();
} catch (IOException e) {
e.printStackTrace();
}
return bytes;
}
代码示例来源:origin: org.jenkins-ci.main/jenkins-core
/**
* Reads the contents of a file.
*/
public InputStream read() throws IOException {
if(file.exists())
try {
return Files.newInputStream(file.toPath());
} catch (InvalidPathException e) {
throw new IOException(e);
}
// check if the compressed file exists
if(gz.exists())
try {
return new GZIPInputStream(Files.newInputStream(gz.toPath()));
} catch (InvalidPathException e) {
throw new IOException(e);
}
// no such file
throw new FileNotFoundException(file.getName());
}
代码示例来源:origin: org.jenkins-ci.plugins/cloudbees-folder
/**
* Returns an input stream that reads from the log file.
* It will use a gzip-compressed log file (log.gz) if that exists.
*
* @return An input stream from the log file.
* If the log file does not exist, the error message will be returned to the output.
* @throws IOException if things go wrong
*/
@Nonnull
public InputStream getLogInputStream() throws IOException {
File logFile = getLogFile();
if (logFile.exists()) {
// Checking if a ".gz" file was return
FileInputStream fis = new FileInputStream(logFile);
if (logFile.getName().endsWith(".gz")) {
return new GZIPInputStream(fis);
} else {
return fis;
}
}
String message = "No such file: " + logFile;
return new ByteArrayInputStream(message.getBytes(Charsets.UTF_8));
}
代码示例来源:origin: org.jenkins-ci.main/jenkins-core
/**
* Returns an input stream that reads from the log file.
* It will use a gzip-compressed log file (log.gz) if that exists.
*
* @throws IOException
* @return An input stream from the log file.
* If the log file does not exist, the error message will be returned to the output.
* @since 1.349
*/
public @Nonnull InputStream getLogInputStream() throws IOException {
File logFile = getLogFile();
if (logFile.exists() ) {
// Checking if a ".gz" file was return
try {
InputStream fis = Files.newInputStream(logFile.toPath());
if (logFile.getName().endsWith(".gz")) {
return new GZIPInputStream(fis);
} else {
return fis;
}
} catch (InvalidPathException e) {
throw new IOException(e);
}
}
String message = "No such file: " + logFile;
return new ByteArrayInputStream(charset != null ? message.getBytes(charset) : message.getBytes());
}
代码示例来源:origin: jenkinsci/cloudbees-folder-plugin
/**
* Returns an input stream that reads from the log file.
* It will use a gzip-compressed log file (log.gz) if that exists.
*
* @return An input stream from the log file.
* If the log file does not exist, the error message will be returned to the output.
* @throws IOException if things go wrong
*/
@Nonnull
public InputStream getLogInputStream() throws IOException {
File logFile = getLogFile();
if (logFile.exists()) {
// Checking if a ".gz" file was return
FileInputStream fis = new FileInputStream(logFile);
if (logFile.getName().endsWith(".gz")) {
return new GZIPInputStream(fis);
} else {
return fis;
}
}
String message = "No such file: " + logFile;
return new ByteArrayInputStream(message.getBytes(Charsets.UTF_8));
}
代码示例来源:origin: org.jenkins-ci.main/jenkins-core
private ConsoleAnnotator createAnnotator(StaplerRequest req) throws IOException {
try {
String base64 = req!=null ? req.getHeader("X-ConsoleAnnotator") : null;
if (base64!=null) {
Cipher sym = PASSING_ANNOTATOR.decrypt();
ObjectInputStream ois = new ObjectInputStreamEx(new GZIPInputStream(
new CipherInputStream(new ByteArrayInputStream(Base64.decode(base64.toCharArray())),sym)),
Jenkins.getInstance().pluginManager.uberClassLoader);
try {
long timestamp = ois.readLong();
if (TimeUnit.HOURS.toMillis(1) > abs(System.currentTimeMillis()-timestamp))
// don't deserialize something too old to prevent a replay attack
return (ConsoleAnnotator)ois.readObject();
} finally {
ois.close();
}
}
} catch (ClassNotFoundException e) {
throw new IOException(e);
}
// start from scratch
return ConsoleAnnotator.initial(context==null ? null : context.getClass());
}
代码示例来源:origin: org.jenkins-ci.main/jenkins-core
public InputStream extract(InputStream _in) throws IOException {
HeadBufferingStream in = new HeadBufferingStream(_in,SIDE_BUFFER_SIZE);
try {
return new GZIPInputStream(in, 8192, true);
} catch (IOException e) {
// various people reported "java.io.IOException: Not in GZIP format" here, so diagnose this problem better
in.fillSide();
throw new IOException(e.getMessage()+"\nstream="+Util.toHexString(in.getSideBuffer()),e);
}
}
public OutputStream compress(OutputStream out) throws IOException {
代码示例来源:origin: org.jruby/jruby-complete
public IRubyObject initialize(ThreadContext context, IRubyObject stream) {
Ruby runtime = context.runtime;
realIo = stream;
try {
// don't close realIO
ioInputStream = new IOInputStream(realIo);
io = new GZIPInputStream(ioInputStream, 512, false);
// JRUBY-4502
// CRuby expects to parse gzip header in 'new'.
io.readHeader();
} catch (IOException e) {
RaiseException re = RubyZlib.newGzipFileError(runtime, "not in gzip format");
byte[] input = io.getAvailIn();
if (input != null && input.length > 0) {
RubyException rubye = re.getException();
rubye.setInstanceVariable("@input",
RubyString.newString(runtime, new ByteList(input, 0, input.length)));
}
throw re;
}
position = 0;
line = 0;
bufferedStream = new PushbackInputStream(new BufferedInputStream(io), 512);
return this;
}
代码示例来源:origin: org.jruby/jruby-core
public IRubyObject initialize(ThreadContext context, IRubyObject stream) {
Ruby runtime = context.runtime;
realIo = stream;
try {
// don't close realIO
ioInputStream = new IOInputStream(realIo);
io = new GZIPInputStream(ioInputStream, 512, false);
// JRUBY-4502
// CRuby expects to parse gzip header in 'new'.
io.readHeader();
} catch (IOException e) {
RaiseException re = RubyZlib.newGzipFileError(runtime, "not in gzip format");
byte[] input = io.getAvailIn();
if (input != null && input.length > 0) {
RubyException rubye = re.getException();
rubye.setInstanceVariable("@input",
RubyString.newString(runtime, new ByteList(input, 0, input.length)));
}
throw re;
}
position = 0;
line = 0;
bufferedStream = new PushbackInputStream(new BufferedInputStream(io), 512);
return this;
}
代码示例来源:origin: org.sonatype.nexus.ruby/nexus-ruby-tools
/**
* add a spec (Ruby Object) to the specs.4.8 indices.
*/
private void addSpecToIndex(IRubyObject spec) throws IOException {
SpecsHelper specs = gateway.newSpecsHelper();
for (SpecsIndexType type : SpecsIndexType.values()) {
SpecsIndexZippedFile specsIndex = ensureSpecsIndexZippedFile(type);
try (InputStream in = new GZIPInputStream(store.getInputStream(specsIndex))) {
try (InputStream result = specs.addSpec(spec, in, type)) {
// if nothing was added the content is NULL
if (result != null) {
store.update(IOUtil.toGzipped(result), specsIndex);
}
}
}
}
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
@JRubyMethod(name = "initialize", visibility = PRIVATE, compat = RUBY1_8)
public IRubyObject initialize(ThreadContext context, IRubyObject stream) {
Ruby runtime = context.runtime;
realIo = stream;
try {
// don't close realIO
ioInputStream = new IOInputStream(realIo);
io = new GZIPInputStream(ioInputStream, 512, false);
// JRUBY-4502
// CRuby expects to parse gzip header in 'new'.
io.readHeader();
} catch (IOException e) {
RaiseException re = RubyZlib.newGzipFileError(runtime, "not in gzip format");
if (getRuntime().is1_9()) {
byte[] input = io.getAvailIn();
if (input != null && input.length > 0) {
RubyException rubye = re.getException();
rubye.setInstanceVariable("@input",
RubyString.newString(runtime, new ByteList(input, 0, input.length)));
}
}
throw re;
}
position = 0;
line = 0;
bufferedStream = new BufferedInputStream(io);
return this;
}
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
@JRubyMethod(name = "initialize", visibility = PRIVATE, compat = RUBY1_8)
public IRubyObject initialize(ThreadContext context, IRubyObject stream) {
Ruby runtime = context.runtime;
realIo = stream;
try {
// don't close realIO
ioInputStream = new IOInputStream(realIo);
io = new GZIPInputStream(ioInputStream, 512, false);
// JRUBY-4502
// CRuby expects to parse gzip header in 'new'.
io.readHeader();
} catch (IOException e) {
RaiseException re = RubyZlib.newGzipFileError(runtime, "not in gzip format");
if (getRuntime().is1_9()) {
byte[] input = io.getAvailIn();
if (input != null && input.length > 0) {
RubyException rubye = re.getException();
rubye.setInstanceVariable("@input",
RubyString.newString(runtime, new ByteList(input, 0, input.length)));
}
}
throw re;
}
position = 0;
line = 0;
bufferedStream = new BufferedInputStream(io);
return this;
}
内容来源于网络,如有侵权,请联系作者删除!