Load the model from the given input stream
@param stream the path of the file to "guess"

@return the loaded model
@throws Exception
347176
public static Object loadConfigGuess(InputStream stream) throws Exception {
        String p = System.getProperty(DL4JSystemProperties.DL4J_TEMP_DIR_PROPERTY);
        File tmp = DL4JFileUtils.createTempFile("model-" + UUID.randomUUID().toString(), "bin");
        BufferedOutputStream bufferedOutputStream = new BufferedOutputStream(new FileOutputStream(tmp));
        IOUtils.copy(stream, bufferedOutputStream);
        bufferedOutputStream.flush();
        bufferedOutputStream.close();
        tmp.deleteOnExit();
        try {
            return loadConfigGuess(tmp.getAbsolutePath());
        } finally {
            tmp.delete();
        }
    }
1244977
public static ObjectStream<Parse> getParseStream(final String inputData)
      throws IOException {
    final ObjectStream<String> parseStream = IOUtils
        .readFileIntoMarkableStreamFactory(inputData);
    final ObjectStream<Parse> samples = new ParseSampleStream(parseStream);
    return samples;
  }
273165
public void load(InputStream in) {
    try {
      PropertiesConfiguration config = new PropertiesConfiguration();
      // disabled to prevent accumulo classpath value from being shortened
      config.setDelimiterParsingDisabled(true);
      config.load(in);
      ((CompositeConfiguration) internalConfig).addConfiguration(config);
    } catch (ConfigurationException e) {
      throw new IllegalArgumentException(e);
    }
  }
781378
public static ApplicationConfiguration load(InputStream input) throws Exception {
		XMLStreamReader xml = XMLInputFactory.newFactory().createXMLStreamReader(input);
		while (xml.hasNext()) {
			xml.next();
			if (xml.getEventType() == XMLStreamConstants.START_ELEMENT) {
				if (!"project".equals(xml.getLocalName()))
					throw new Exception("Root element of an lc-project.xml file must be <project>");
				ApplicationConfiguration cfg = new ApplicationConfiguration();
				boolean found = false;
				while (xml.hasNext()) {
					xml.next();
					if (xml.getEventType() == XMLStreamConstants.START_ELEMENT) {
						if ("application".equals(xml.getLocalName())) {
							found = true;
							cfg.load(xml);
							break;
						}
					}
				}
				if (!found)
					throw new Exception("No application element found in lc-project.xml file");
				return cfg;
			}
		}
		throw new Exception("Nothing found in lc-project.xml file");
	}
985012
private void readObject(ObjectInputStream stream)
            throws IOException, ClassNotFoundException {

        stream.defaultReadObject();

        initInternal();

        isTimeSet = true;
        areFieldsSet = areAllFieldsSet = false;
        areFieldsVirtuallySet = true; // cause fields to be recalculated if requested.
        nextStamp = MINIMUM_USER_STAMP;
    }
1098125
public void load(InputStream stream, String separator) throws IOException, PropertiesException {
		 
		try(DataInputStream data = new DataInputStream(stream); Reader reader = new InputStreamReader(data); BufferedReader br = new BufferedReader(reader)) {
			String line;
			StringBuilder buffer = new StringBuilder();
			while ((line = br.readLine()) != null)   {
				if(Strings.trimRight(line).startsWith(LINE_COMMENT_START)) {
					// comment line, skip!
					continue;
				} else {					
					// now check if multi-line property
					if(line.endsWith(CONTINUE_ON_NEW_LINE)) {
						// middle line in multi-line, add and skip parsing
						buffer.append(line.replaceFirst("\\\\$", ""));
						continue;
					} else {
						// ordinary line, or end of multi-line: add and parse
						buffer.append(line);
					}
				}
				line = buffer.toString().trim();
				buffer.setLength(0);
				int index = -1;
				if(line.length() > 0 && (index = line.lastIndexOf(separator)) != -1) {
					String key = line.substring(0, index).trim();
					String value = line.substring(index + separator.length()).trim();
					if("@".equals(key)) {
						logger.trace("including and overriding values defined so far with file '{}'", value);
						load(value, separator);
					} else {
						logger.trace("adding '{}' => '{}'", key, value);
						this.put(key.trim(), value.trim());
					}
				}
			}
			if(buffer.length() > 0) {
				logger.warn("multi-line property '{}' is not properly terminated", buffer);
			}
		}
	}
1304389
public static Model load(String modelPath) throws Exception {
        Model model = new CRFModel();
        if (model.checkModel(modelPath)) {
            return model.loadModel(modelPath);
        }
        model = new CRFppTxtModel();

        if (model.checkModel(modelPath)) {
            return model.loadModel(modelPath);
        }
        model = new WapitiCRFModel();
        if (model.checkModel(modelPath)) {
            return model.loadModel(modelPath);
        }
        throw new Exception("I did not know what type of model by file " + modelPath);
    }
1363829
@Override
    public Storingen getModel(InputStream stream) {
        SimpleDateFormat format = new SimpleDateFormat(NsApi.DATETIME_FORMAT);
        try {
            List<Storing> geplandeStoringen = new LinkedList<>();
            List<Storing> ongeplandeStoringen = new LinkedList<>();

            Xml xml = Xml.getXml(stream, "Storingen");
            if (xml.isPresent("Ongepland")) {
                Xml ongeplandeStoringenXml = xml.child("Ongepland");
                for (Xml storingXml : ongeplandeStoringenXml.children("Storing")) {
                    ongeplandeStoringen.add(getStoring(storingXml, format));
                }
            }
            if (xml.isPresent("Gepland")) {
                Xml geplandeStoringenXml = xml.child("Gepland");
                for (Xml storingXml : geplandeStoringenXml.children("Storing")) {
                    geplandeStoringen.add(getStoring(storingXml, format));
                }
            }
            return new Storingen(ongeplandeStoringen, geplandeStoringen);
        }
        catch (ParseException e) {
            logger.error("Error parsing stream to actuele vertrektijden", e);
            throw new NsApiException("Error parsing stream to actuele vertrektijden", e);
        }
    }
1285093
public static InputStream loadFile(String fileName) {
        logger.entering(fileName);
        ClassLoader loader = Thread.currentThread().getContextClassLoader();
        InputStream iStream = loader.getResourceAsStream(fileName);
        if (iStream == null) {
            try {
                iStream = new FileInputStream(fileName);
            } catch (FileNotFoundException e) { // NOSONAR
                // Gobbling the checked exception here and doing nothing with it
                // because we are explicitly checking if the inputstream is null
                // and then throwing a runtime exception
            }
        }
        if (iStream == null) {
            throw new IllegalArgumentException("[" + fileName + "] is not a valid resource");
        }
        logger.exiting();
        return iStream;
    }
1364442
public static void loadFrom(InputStream in, Proto target) throws Exception
    {
        loadFrom(new ANTLRInputStream(in), target);
    }
178065
private Set<String> loadWords(InputStream stream) throws IOException {
    Set<String> words = new HashSet<>();
    try (
      InputStreamReader isr = new InputStreamReader(stream, "UTF-8");
      BufferedReader br = new BufferedReader(isr)
    ) {
      String line;
      while ((line = br.readLine()) != null) {
        line = line.trim();
        if (line.isEmpty() || line.charAt(0) == '#') {  // ignore comments
          continue;
        }
        words.add(line);
      }
    }
    return words;
  }
1175879
@SuppressWarnings("unchecked")
  private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException {
    int capacity = stream.readInt();
    initialize(capacity);
    int size = stream.readInt();
    for (int i = 0; i < size; i++) {
      addEntry((K) stream.readObject(), (V) stream.readObject());
    }
  }
942175
public void loadModel(String modelfile) throws IOException,
			ClassNotFoundException {
		ObjectInputStream instream = new ObjectInputStream(new GZIPInputStream(
				new FileInputStream(modelfile)));
		factory = (AlphabetFactory) instream.readObject();
		models = (Linear[]) instream.readObject();
		instream.close();
		IFeatureAlphabet features = factory.DefaultFeatureAlphabet();
		features.setStopIncrement(true);
	}
634550
public void load(ObjectInputStream in, V[] value) throws IOException, ClassNotFoundException
    {
        base = (int[]) in.readObject();
        check = (int[]) in.readObject();
        fail = (int[]) in.readObject();
        output = (int[][]) in.readObject();
        l = (int[]) in.readObject();
        v = value;
    }
119713
public void open(InputStream stream) throws IOException
    {

        int size = (int) (stream.available() / UNIT_SIZE);
        _array = new int[size];

        DataInputStream in = null;
        try
        {
            in = new DataInputStream(new BufferedInputStream(
                    stream));
            for (int i = 0; i < size; ++i)
            {
                _array[i] = in.readInt();
            }
        }
        finally
        {
            if (in != null)
            {
                in.close();
            }
        }
    }
496707
public <U> BaseSimpleReactStream<U> fromStream(final Stream<CompletableFuture<U>> stream) {

        final Stream s = stream;
        return construct(s);
    }
366130
public static Object load(Reader reader) throws IOException {
    Map<String, Object> data = getSnakeYaml().load(reader);
    return modelMapper(data);
  }