加载设置文件。 此方法不会关闭流对象

@param settingStream 文件流
@return 加载成功与否
@throws IOException IO异常
962036
public boolean load(InputStream settingStream) throws IOException {
		super.clear();
		BufferedReader reader = null;
		try {
			reader = IoUtil.getReader(settingStream, charset);
			// 分组
			String group = null;
			LinkedHashSet<String> valueSet = null;

			while (true) {
				String line = reader.readLine();
				if (line == null) {
					break;
				}
				line = line.trim();
				// 跳过注释行和空行
				if (StrUtil.isBlank(line) || line.startsWith(COMMENT_FLAG_PRE)) {
					// 空行和注释忽略
					continue;
				} else if (line.startsWith(StrUtil.BACKSLASH + COMMENT_FLAG_PRE)) {
					// 对于值中出现开头为#的字符串，需要转义处理，在此做反转义
					line = line.substring(1);
				}

				// 记录分组名
				if (line.charAt(0) == GROUP_SURROUND[0] && line.charAt(line.length() - 1) == GROUP_SURROUND[1]) {
					// 开始新的分组取值，当出现重名分组时候，合并分组值
					group = line.substring(1, line.length() - 1).trim();
					valueSet = super.get(group);
					if (null == valueSet) {
						valueSet = new LinkedHashSet<String>();
					}
					super.put(group, valueSet);
					continue;
				}

				// 添加值
				if (null == valueSet) {
					// 当出现无分组值的时候，会导致valueSet为空，此时group为""
					valueSet = new LinkedHashSet<String>();
					super.put(StrUtil.EMPTY, valueSet);
				}
				valueSet.add(line);
			}
		} finally {
			IoUtil.close(reader);
		}
		return true;
	}
1312184
public static InputStream asStream(Class<?> contextClass, String resourceName) throws IOException {
		return Resources.getResource(contextClass, resourceName).openStream();
	}
1333418
function addToStream(stream) {
  // Don't add more than once
  if (stream.listeners('addListener').includes(addListener)) {
    return stream;
  }

  stream.on('newListener', addListener);

  return stream;
}
533745
private void copyStream(InputStream inputStream) throws IOException {
		OutputStream outputStream = null;
		try {
			outputStream = getContext().getOutputStream();
			byte[] buffer = new byte[65535];
			int bufferLen;
			int totalLen = 0;
			while ((bufferLen = inputStream.read(buffer)) > 0) {
				outputStream.write(buffer, 0, bufferLen);
				totalLen += bufferLen;
			}
			getContext().getResponse().setContentLength(totalLen);
		} finally {
			if (outputStream != null) {
				outputStream.flush();
			}
		}
	}
93764
private static InputStream createInputStream(GraphicFactory graphicFactory, String relativePathPrefix, String src) throws IOException {
        InputStream inputStream;
        if (src.startsWith(PREFIX_ASSETS)) {
            src = src.substring(PREFIX_ASSETS.length());
            inputStream = inputStreamFromAssets(graphicFactory, relativePathPrefix, src);
        } else if (src.startsWith(PREFIX_FILE)) {
            src = src.substring(PREFIX_FILE.length());
            inputStream = inputStreamFromFile(relativePathPrefix, src);
        } else if (src.startsWith(PREFIX_JAR) || src.startsWith(PREFIX_JAR_V1)) {
            if (src.startsWith(PREFIX_JAR)) {
                src = src.substring(PREFIX_JAR.length());
            } else if (src.startsWith(PREFIX_JAR_V1)) {
                src = src.substring(PREFIX_JAR_V1.length());
            }
            inputStream = inputStreamFromJar(relativePathPrefix, src);
        } else {
            inputStream = inputStreamFromFile(relativePathPrefix, src);

            if (inputStream == null) {
                inputStream = inputStreamFromAssets(graphicFactory, relativePathPrefix, src);
            }

            if (inputStream == null) {
                inputStream = inputStreamFromJar(relativePathPrefix, src);
            }
        }

        // Fallback to internal resources
        if (inputStream == null) {
            inputStream = inputStreamFromJar("/assets/", src);
            if (inputStream != null) {
                LOGGER.info("internal resource: " + src);
            }
        }

        if (inputStream != null) {
            return inputStream;
        }

        LOGGER.severe("invalid resource: " + src);
        throw new FileNotFoundException("invalid resource: " + src);
    }
196356
private void loadStream(InputStream stream)
    {
        int            iPos       = -1;
        String         strLine    = null;
        String         strSection = null;
        String         strRemarks = null;
        BufferedReader objBRdr    = null;
        InputStreamReader     objFRdr    = null;
        INISection     objSec     = null;

        try
        {
            objFRdr = new InputStreamReader(stream);
            if (objFRdr != null)
            {
                objBRdr = new BufferedReader(objFRdr);
                if (objBRdr != null)
                {
                    while (objBRdr.ready())
                    {
                        iPos = -1;
                        strLine  = null;
                        strLine = objBRdr.readLine().trim();
                        if (strLine == null)
                        {
                        }
                        else if (strLine.length() == 0)
                        {
                        }
                        else if (strLine.substring(0, 1).equals(";"))
                        {
                            if (strRemarks == null)
                                strRemarks = strLine.substring(1);
                            else if (strRemarks.length() == 0)
                                strRemarks = strLine.substring(1);
                            else
                                strRemarks = strRemarks + "\r\n" + strLine.substring(1);
                        }
                        else if (strLine.startsWith("[") && strLine.endsWith("]"))
                        {
                            // Section start reached create new section
                            if (objSec != null) 
                                this.mhmapSections.put(strSection.trim(), objSec);
                            objSec = null;
                            strSection = strLine.substring(1, strLine.length() - 1);
                            objSec = new INISection(strSection.trim(), strRemarks);
                            strRemarks = null;
                        }
                        else if ((iPos = strLine.indexOf("=")) > 0 && objSec != null)
                        {
                            // read the key value pair 012345=789
                            objSec.setProperty(strLine.substring(0, iPos).trim(), 
                                                strLine.substring(iPos + 1).trim(), 
                                                strRemarks);
                            strRemarks = null;
                        }
                        else 
                        {
                            objSec.setProperty(strLine, "", strRemarks);
                      
                        }
                    }
                    if (objSec != null)
                        this.mhmapSections.put(strSection.trim(), objSec);
                    this.mblnLoaded = true;
                }
            }
        }
        catch (FileNotFoundException FNFExIgnore)
        {
            this.mhmapSections.clear();
        }
        catch (IOException IOExIgnore)
        {
            this.mhmapSections.clear();
        }
        catch (NullPointerException NPExIgnore)
        {
            this.mhmapSections.clear();
        }
        finally
        {
            if (objBRdr != null)
            {
                closeReader(objBRdr);
                objBRdr = null;
            }
            if (objFRdr != null)
            {
                closeReader(objFRdr);
                objFRdr = null;
            }
            if (objSec != null) objSec = null;
        }
    }
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();
        }
    }
1012627
public OperationBuilder addInputStream(final InputStream in) {
        Assert.checkNotNullParam("in", in);
        if (inputStreams == null) {
            inputStreams = new ArrayList<InputStream>();
        }
        inputStreams.add(in);
        return this;
    }
766417
public boolean load(UrlResource urlResource) {
		if (urlResource == null) {
			throw new NullPointerException("Null setting url define!");
		}
		log.debug("Load setting file [{}]", urlResource);
		InputStream settingStream = null;
		try {
			settingStream = urlResource.getStream();
			load(settingStream);
		} catch (Exception e) {
			log.error(e, "Load setting error!");
			return false;
		} finally {
			IoUtil.close(settingStream);
		}
		return true;
	}
1051350
public static NetworkConfig fromYamlStream(InputStream configStream) throws InvalidArgumentException, NetworkConfigurationException {

        logger.trace("NetworkConfig.fromYamlStream...");

        // Sanity check
        if (configStream == null) {
            throw new InvalidArgumentException("configStream must be specified");
        }

        Yaml yaml = new Yaml();

        @SuppressWarnings ("unchecked")
        Map<String, Object> map = yaml.load(configStream);

        JsonObjectBuilder builder = Json.createObjectBuilder(map);

        JsonObject jsonConfig = builder.build();
        return fromJsonObject(jsonConfig);
    }
199369
public static void append(File self, InputStream stream) throws IOException {
        OutputStream out = new FileOutputStream(self, true);
        try {
            IOGroovyMethods.leftShift(out, stream);
        } finally {
            closeWithWarning(out);
        }
    }
427945
public void addStream(Stream stream) {
        indexSets.add(stream.getIndexSet());
        if (streams.add(stream)) {
            sizeCounter.inc(8);
            if (LOG.isTraceEnabled()) {
                LOG.trace("[Message size update][{}] stream added: {}", getId(), sizeCounter.getCount());
            }
        }
    }
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);
			}
		}
	}
612471
public void configure(InputStream is) throws IOException {
        try (BufferedReader reader = new BufferedReader(new InputStreamReader(is))) {
            int lineNumber = 0;

            while (true) {
                String line = reader.readLine();
                if (line == null) break;

                line = line.trim();
                lineNumber++;

                if (line.startsWith("#") || line.length() == 0) continue;

                if (line.startsWith(LOAD_PREFIX)) {
                    String loadPath = line.substring(LOAD_PREFIX.length()).trim();
                    loadPath = assignProperties(loadPath);
                    loadFilteredPath(loadPath);
                } else if (line.startsWith(GRAB_PREFIX)) {
                    String grabParams = line.substring(GRAB_PREFIX.length()).trim();
                    grabList.add(assignProperties(grabParams));
                } else if (line.startsWith(MAIN_PREFIX)) {
                    if (main != null)
                        throw new IOException("duplicate definition of main in line " + lineNumber + " : " + line);
                    main = line.substring(MAIN_PREFIX.length()).trim();
                } else if (line.startsWith(PROP_PREFIX)) {
                    String params = line.substring(PROP_PREFIX.length()).trim();
                    String key = SystemUtil.setSystemPropertyFrom(params);
                    System.setProperty(key, assignProperties(System.getProperty(key)));
                } else if (line.startsWith(CONFIGSCRIPT_PREFIX)) {
                    String script = line.substring(CONFIGSCRIPT_PREFIX.length()).trim();
                    configScripts.add(assignProperties(script));
                } else {
                    throw new IOException("unexpected line in " + lineNumber + " : " + line);
                }
            }
        }

        if (requireMain && main == null) throw new IOException("missing main class definition in config file");
        if (!configScripts.isEmpty()) {
            System.setProperty("groovy.starter.configscripts", DefaultGroovyMethods.join((Iterable)configScripts, ","));
        }
    }
246380
public void load(InputStream inputStream) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
        StringBuilder out = new StringBuilder();
        String line;

        while ((line = reader.readLine()) != null) {
            out.append(line);
            out.append(System.lineSeparator());
        }

        setScriptText(out.toString());
    }
1215217
public static FileIndex read(InputStream stream) throws IOException {
        //Creating raw input stream
        DataInputStream raw = new DataInputStream(stream);

        //Reading magic number
        int magic = raw.readInt();
        if (magic != MAGIC)
            throw new IOException("Wrong magic number");

        //Reading length
        int length = raw.readInt();

        //Reading whole index
        byte[] buffer = new byte[length];
        raw.read(buffer);

        //Creating uncompressed stream
        InflaterInputStream inflater = new InflaterInputStream(new ByteArrayInputStream(buffer));
        DataInputStream dataStream = new DataInputStream(inflater);

        //Reading step
        long step = dataStream.readLong();
        long startingRecordNumner = dataStream.readLong();
        long lastRecordNumber = dataStream.readLong();

        //Reading meta record count
        int metaRecordsCount = dataStream.readInt();

        //Reading meta records
        Map<String, String> metadata = new HashMap<>();
        String key, value;
        while (--metaRecordsCount >= 0) {
            key = dataStream.readUTF();
            value = dataStream.readUTF();
            metadata.put(key, value);
        }

        //Reading entries number
        int size = dataStream.readInt();

        //Creating array for index
        TLongArrayList index = new TLongArrayList(size);

        //Reading index
        long last = 0, val;
        for (int i = 0; i < size; ++i) {
            val = IOUtil.readRawVarint64(dataStream, -1);
            if (val == -1)
                throw new IOException("Wrong file format");
            last += val;
            index.add(last);
        }

        return new FileIndex(step, metadata, index, startingRecordNumner, lastRecordNumber);
    }
274692
public static ParameterTool fromPropertiesFile(InputStream inputStream) throws IOException {
		Properties props = new Properties();
		props.load(inputStream);
		return fromMap((Map) props);
	}