Module: IOConvert
- Defined in:
- lib/marc4j4r.rb
Overview
Define a method that will take a string (filename), IO object, or StringIO object, and return an inputstream/outputstream
Class Method Summary collapse
Class Method Details
.byteinstream(fromwhere) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/marc4j4r.rb', line 36 def byteinstream(fromwhere) stream = nil if fromwhere.is_a? Java::JavaIO::InputStream stream = fromwhere elsif fromwhere.is_a? String stream = java.io.FileInputStream.new(fromwhere.to_java_string) elsif fromwhere.respond_to? :to_inputstream stream = fromwhere.to_inputstream end return stream end |
.byteoutstream(towhere) ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/marc4j4r.rb', line 48 def byteoutstream towhere stream = nil if towhere.is_a? Java::JavaIO::OutputStream stream = towhere elsif towhere.is_a? String stream = java.io.FileOutputStream.new(towhere.to_java_string) elsif towhere.respond_to? :to_outputstream stream = towhere.to_outputstream end return stream end |