Module: JavaStreamify
- Defined in:
- lib/java_streamify.rb
Class Method Summary collapse
Class Method Details
.inputstream(from, opts = {}) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/java_streamify.rb', line 6 def self.inputstream(from, opts = {}) gzip = opts[:gz] || opts[:gzip] stream = nil if from.is_a? Java::JavaIO::InputStream stream = from elsif from.is_a? String stream = java.io.FileInputStream.new(from.to_java_string) gzip = true if from =~ /\.gz$/ elsif from.respond_to? :to_inputstream stream = from.to_inputstream end if gzip stream = Java::java.util.zip.GZIPInputStream.new(stream) end return stream end |
.outputstream(from, opts = {}) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/java_streamify.rb', line 25 def self.outputstream(from, opts={}) stream = nil gzip = opts[:gz] || opts[:gzip] if from.is_a? Java::JavaIO::OutputStream stream = from elsif from.is_a? String stream = java.io.FileOutputStream.new(from.to_java_string) gzip = true if from =~ /\.gz$/ elsif from.respond_to? :to_outputstream stream = from.to_outputstream end if gzip stream = Java::java.util.zip.GZIPOutputStream.new(stream) end return stream end |