Creates an InputStream containing the document resulting from replacing template
parameters in the given file.
@param file The template file
@param props The properties
@return An InputStream containing the resulting document.
760574
static public InputStream replaceProperties(File file, Properties props) throws IOException, SubstitutionException {
	return replaceProperties(new FileInputStream(file), props);
    }
1005324
public static PropertiesSettings from(File file) throws IOException
    {
        FileInputStream stream = new FileInputStream(file);
        return from(stream);
    }
761848
public static Props loadProps(final Props parent, final File... propFiles) {
    try {
      Props props = new Props(parent);
      for (final File f : propFiles) {
        if (f.isFile()) {
          props = new Props(props, f);
        }
      }

      return props;
    } catch (final IOException e) {
      throw new RuntimeException("Error loading properties.", e);
    }
  }
1173121
private Document readDocument(InputStream in, URI file) throws TransformerConfigurationException, SAXException, IOException {
        final Document document = documentBuilder.newDocument();
        if (file != null) {
            document.setDocumentURI(file.toString());
        }

        final TransformerHandler domSerializer = saxTransformerFactory.newTransformerHandler();
        domSerializer.setResult(new DOMResult(document));
        final InputSource inputSource = new InputSource(in);
        if (file != null) {
            inputSource.setSystemId(file.toString());
        }
        validator.validate(new SAXSource(inputSource), new SAXResult(domSerializer));

        return document;
    }
481867
public static Properties loadProperties(File f) throws IOException {
        Properties props = new Properties();
        FileInputStream in = new FileInputStream(f);
        try {
            props.load(in);
            return props;
        } finally {
            try {
                in.close();
            } catch (IOException e) {
            }
        }
    }
1243559
public static String convertToHocon(File props) throws IOException {
        StringBuilder output = new StringBuilder();
        List<String> lines = FileUtils.readLines(props);


        boolean readingValue = false;
        for (String line : lines) {
            if (isComment(line)) {
                // Comment
                output.append("#").append(line.trim().substring(1)).append("\n");
                continue;
            }

            if (line.trim().isEmpty()) {
                if (!readingValue) {
                    output.append("\n");
                }
                continue;
            }

            if (!readingValue) {
                int position = getKeyValueSeparatorPosition(line);
                if (position != 0) {
                    String key = line.substring(0, position).trim();
                    int vPosition = getValueStartPosition(line, position);
                    String value;
                    if (vPosition == -1) {
                        // No value
                        value = "";
                    } else {
                        value = fixValue(line.substring(vPosition).trim());
                    }
                    output.append(fixKey(key)).append("=");
                    if (value.endsWith("\\")) {
                        // Multiline
                        readingValue = true;
                        output.append("\"");
                        output.append(value.substring(0, value.length() - 1));
                    } else {
                        if (vPosition == -1) {
                            output.append("\"\"");
                        } else {
                            output.append(fixSingleLineValue(line.substring(vPosition)).trim()).append("\n");
                        }
                        readingValue = false;
                    }
                } else {
                    throw new IllegalStateException("No key-value separator found in " + line);
                }
            } else {
                String value = line.trim();
                if (value.endsWith("\\")) {
                    // Multiline
                    readingValue = true;
                    output.append(fixValue(value.substring(0, value.length() - 1)));
                } else {
                    output.append(fixValue(value)).append("\"\n");
                    readingValue = false;
                }
            }
        }

        return output.toString();

    }
182719
public static String file(File file) throws IOException {
        InputStream in = null;
        try {
            in = new FileInputStream(file);
            return stream(in, file.length());
        } finally {
            if (in != null) {
                try {
                    in.close();
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }
    }
1227480
function(props) {
        var files = {};
        // Iterate over all source files.
        grunt.task.expandFiles({dot: true}, pathPrefix + '**').forEach(function(obj) {
          // Get the path relative to the template root.
          var relpath = obj.rel.slice(pathPrefix.length);
          var rule = init.renames[relpath];
          // Omit files that have an empty / false rule value.
          if (!rule && relpath in init.renames) { return; }
          // Create a property for this file.
          files[rule ? grunt.template.process(rule, props, 'init') : relpath] = obj.rel;
        });
        return files;
      }
218508
function(props) {
        var files = {};
        // Include all template files by default.
        helpers.expand({filter: 'isFile', dot: true}, [pathPrefix + '**']).forEach(function(obj) {
          // Get the source filepath relative to the template root.
          var src = obj.rel.slice(pathPrefix.length);
          // Get the destination filepath.
          var dest = init.renames[src];
          // Create a property for this file, but use src if dest evaulates
          // to false
          var processed = (dest) ? grunt.template.process(dest, {data: props, delimiters: 'init'}) : false;
          processed = (processed === 'false' || processed === '') ? false : processed;
          files[(processed) ? processed : src] = obj.rel;
        });
        // Exclude files with a value of false in rename.json.
        var exclusions = Object.keys(init.renames).filter(function(key) {
          var processed = (init.renames[key]) ? 
            grunt.template.process(init.renames[key], {data: props, delimiters: 'init'}) : false;
          processed = (processed === 'false' || processed === '') ? false : processed;
          return (processed === false);
        }).map(function(key) {
          return pathPrefix + key;
        });
        // Exclude all exclusion files by deleting them from the files object.
        if (exclusions.length > 0) {
          helpers.expand({filter: 'isFile', dot: true}, exclusions).forEach(function(obj) {
            // Get the source filepath relative to the template root.
            var src = obj.rel.slice(pathPrefix.length);
            // And remove that file from the files list.
            delete files[src];
          });
        }
        return files;
      }
593682
public static void write(InputStream in, File file) {
        write(in, file.toPath(), StandardCopyOption.REPLACE_EXISTING);
    }
807400
function(files, props, options) {
        options = grunt.utils._.defaults(options || {}, {
          process: function(contents) {
            return grunt.template.process(contents, props, 'init');
          }
        });
        Object.keys(files).forEach(function(destpath) {
          var o = Object.create(options);
          var srcpath = files[destpath];
          // If srcpath is relative, match it against options.noProcess if
          // necessary, then make srcpath absolute.
          var relpath;
          if (srcpath && !grunt.file.isPathAbsolute(srcpath)) {
            if (o.noProcess) {
              relpath = srcpath.slice(pathPrefix.length);
              o.noProcess = grunt.file.isMatch(o.noProcess, relpath);
            }
            srcpath = grunt.task.getFile(srcpath);
          }
          // Copy!
          init.copy(srcpath, destpath, o);
        });
      }
897520
public static <T extends File> T createFile(final SecurityContext securityContext, final InputStream fileStream, final Class<T> fileType, final PropertyMap props)
		throws FrameworkException, IOException {

		T newFile = (T) StructrApp.getInstance(securityContext).create(fileType, props);

		setFileData(newFile, fileStream, props.get(StructrApp.key(File.class, "contentType")));

		// schedule indexing
		newFile.notifyUploadCompletion();

		return newFile;
	}
1149021
public Configuration create(File file) {
        try {
            Configuration configuration;
            InputStream stream = new BufferedInputStream(new FileInputStream(file));
            try {
                configuration = create(stream);
            } finally {
                stream.close();
            }
            return configuration;
        } catch (IOException e) {
            throw new TextProcessorFactoryException(e);
        }
    }
1306968
@Override
    public T fromFile(final File file) throws IllegalArgumentException, DescriptorImportException {
        // Precondition checks
        if (file == null) {
            throw new IllegalArgumentException("File not specified");
        }

        // Delegate
        try {
            return this.fromStream(new FileInputStream(file));
        } catch (final FileNotFoundException e) {
            throw new IllegalArgumentException("Specified file does not exist or is a directory: "
                + file.getAbsolutePath());
        }
    }
233830
@SuppressWarnings("unchecked") // yaml.load API returns raw Map
  public static Map<String, Object> loadStream(InputStream inputStream) {
    LOG.fine("Reading config stream");

    Yaml yaml = new Yaml();
    Map<Object, Object> propsYaml = (Map<Object, Object>) yaml.load(inputStream);
    LOG.fine("Successfully read config");

    Map<String, Object> typedMap = new HashMap<>();
    for (Object key: propsYaml.keySet()) {
      typedMap.put(key.toString(), propsYaml.get(key));
    }

    return typedMap;
  }
523071
public void loadFromYAML(final Properties props, final InputStream is) throws IOException {
		try {
			((PrefixedProperties) props).loadFromYAML(is);
		} catch (final NoSuchMethodError err) {
			throw new IOException(
					"Cannot load properties JSON file - not using PrefixedProperties: " + err.getMessage());
		}
	}
274692
public static ParameterTool fromPropertiesFile(InputStream inputStream) throws IOException {
		Properties props = new Properties();
		props.load(inputStream);
		return fromMap((Map) props);
	}