Lazy mechanism for stream loading

@param data file

@return lazy stream
486613
public static HasInputStream lazyStream(final InputStream data) {
        return new HasInputStream() {
            @Override
            public InputStream getInputStream() throws IOException {
                return data;
            }

            @Override
            public long writeContent(OutputStream outputStream) throws IOException {
                return copyStream(data, outputStream);
            }
        };
    }
93697
public function stream()
    {
        $stream = fopen($this->file, 'r');

        $stream = $stream === false ? null : $stream;

        return new Stream($stream);
    }
941937
public static <T> T fromByteArrayFst(byte[] data, Class<T> clazz) {
        return fromByteArrayFst(data, clazz, null);
    }
1269148
public static SimpleDataSet loadArffFile(File file) 
    {
        try
        {
            return loadArffFile(new FileReader(file));
        }
        catch (FileNotFoundException ex)
        {
            Logger.getLogger(ARFFLoader.class.getName()).log(Level.SEVERE, null, ex);
            return null;
        }
    }
966118
function (data) {
      var parse = function() {
        var parsed = lazy.extend({}, lazy.parseFilepath(this.path), data);
        if (typeof parsed.ext === 'undefined') {
          parsed.ext = parsed.extname;
        }
        return parsed;
      }.bind(this);
      return this.fragmentCache('path', parse);
    }
1240369
public function load($file, $data = null)
    {
        $data = array_merge($this->data, (array) $data);

        $renderer = $this->createSelf();

        return $renderer->render($file, $data);
    }
635830
def get_stream(data=None):
        
        if len(__mstreams_available__) == 0:
            if data:
                mstream = MemoryStream(data)
                mstream.seek(0)
            else:
                mstream = MemoryStream()
            __mstreams__.append(mstream)
            return mstream

        mstream = __mstreams_available__.pop()

        if data is not None and len(data):
            mstream.clean_up()
            mstream.write(data)

        mstream.seek(0)

        return mstream
261530
public static File writeDataToTempFile(final String data, final String ext) {
		try {
			final File file = createTempFile(ext);
			final PrintWriter out = new PrintWriter(new FileOutputStream(file));
			out.print(data);
//			out.flush();
			out.close();
//			file.deleteOnExit();
			return file;
		} catch (IOException e) {
			JKExceptionUtil.handle(e);
			return null;
		}
	}
467781
@SuppressWarnings("unchecked")
    public BaseBo fromByteArray(byte[] data) {
        Map<String, Object> dataMap = null;
        try {
            dataMap = data != null ? SerializationUtils.fromByteArray(data, Map.class) : null;
        } catch (Exception e) {
            dataMap = null;
        }
        return fromMap(dataMap);
    }
1268757
function readStream(stream) {
  return new Promise(function(resolve) {
    stream.pipe(concat(function(data) {
      resolve(data.toString().trim());
    }));
  });
}
519421
public InputStream getResourceAsStream(String fileName) {
		InputStream retval = super.getResourceAsStream(fileName);

		if (retval == null) {
			//String className = this.convertFileNameToClassName(fileName);
			//Object location = classResourceLocations.get(className);
			Object location = this.mixedResourceLocations.get(fileName);
			if (location == null) {
				return null;
			}

			byte[] data;
			try {
				data = getData(fileName, location);
			} catch (IOException ioe) {
				return null;
			}
			if (data == null) {
				return null;
			}
			return new ByteArrayInputStream(data);

		}
		return retval;
	}
172731
public static <T> Stream<T> create(final Iteration<? extends T, ?> iteration) {
        return new IterationStream<T>(iteration);
    }
238371
private Iterable<Version> loadData(InputStream in) throws IOException, StreamCorruptedException {
        DataInputStream dis = new DataInputStream(in);
        if (dis.readByte() != 1) {
            throw new StreamCorruptedException("File format not recognised");
        }
        // group
        String groupId = dis.readUTF();
        if ("TZDB".equals(groupId) == false) {
            throw new StreamCorruptedException("File format not recognised");
        }
        // versions
        int versionCount = dis.readShort();
        String[] versionArray = new String[versionCount];
        for (int i = 0; i < versionCount; i++) {
            versionArray[i] = dis.readUTF();
        }
        // regions
        int regionCount = dis.readShort();
        String[] regionArray = new String[regionCount];
        for (int i = 0; i < regionCount; i++) {
            regionArray[i] = dis.readUTF();
        }
        regionIds = Arrays.asList(regionArray);
        // rules
        int ruleCount = dis.readShort();
        Object[] ruleArray = new Object[ruleCount];
        for (int i = 0; i < ruleCount; i++) {
            byte[] bytes = new byte[dis.readShort()];
            dis.readFully(bytes);
            ruleArray[i] = bytes;
        }
        AtomicReferenceArray<Object> ruleData = new AtomicReferenceArray<Object>(ruleArray);
        // link version-region-rules
        Set<Version> versionSet = new HashSet<Version>(versionCount);
        for (int i = 0; i < versionCount; i++) {
            int versionRegionCount = dis.readShort();
            String[] versionRegionArray = new String[versionRegionCount];
            short[] versionRulesArray = new short[versionRegionCount];
            for (int j = 0; j < versionRegionCount; j++) {
                versionRegionArray[j] = regionArray[dis.readShort()];
                versionRulesArray[j] = dis.readShort();
            }
            versionSet.add(new Version(versionArray[i], versionRegionArray, versionRulesArray, ruleData));
        }
        return versionSet;
    }
182593
async function convertStream(data, streaming) {
  if (!streaming && util.isStream(data)) {
    return stream.readToEnd(data);
  }
  if (streaming && !util.isStream(data)) {
    data = new ReadableStream({
      start(controller) {
        controller.enqueue(data);
        controller.close();
      }
    });
  }
  if (streaming === 'node') {
    data = stream.webToNode(data);
  }
  return data;
}
475967
public static <T> Stream<T> stream(final Iterable<T> source) {
        return new Stream<T>() {
            @Override
            public Iterator<T> iterator() {
                return source.iterator();
            }
        };
    }
738560
private S getInputStreamForFile(File file) throws IOException {
        assert file != null : "File must be specified";
        return this.getInputStreamForRawStream(new FileInputStream(file));
    }
336533
public <E extends Model> LazyList<E> load() {
        if (hydrated()) { throw new DBException("load() must be the last on the chain of methods"); }
        hydrate();
        return (LazyList<E>) this;
    }