Reads properties from a string.
@param file a properties file
@param logger a logger (not null)
@return a {@link Properties} instance
15921
public static Properties readPropertiesQuietly( String fileContent, Logger logger ) {

		Properties result = new Properties();
		try {
			if( fileContent != null ) {
				InputStream in = new ByteArrayInputStream( fileContent.getBytes( StandardCharsets.UTF_8 ));
				result.load( in );
			}

		} catch( Exception e ) {
			logger.severe( "Properties could not be read from a string." );
			logException( logger, e );
		}

		return result;
	}
1259317
public static List<String> readLines(File file, Charset charset) throws IOException {
    InputStream in = null;
    try {
      in = new FileInputStream(file);
      if (null == charset) {
        return IOs.readLines(new InputStreamReader(in));
      } else {
        InputStreamReader reader = new InputStreamReader(in, charset.name());
        return IOs.readLines(reader);
      }
    } finally {
      IOs.close(in);
    }
  }
872222
public static Properties readProperties(InputStream _stream) {
        Properties props = new Properties();
        if (_stream == null) {
            return null;
        }

        try {
            props.load(_stream);
            return props;
        } catch (IOException | NumberFormatException _ex) {
            LOGGER.warn("Could not properties: ", _ex);
        }
        return null;
    }
802521
public static LogView parse(File file) throws IOException {
                LogView view = (LogView) xstream.fromXML(file);
                view.reinitialize();
                return view;
        }
843106
public static String readFromFileIntoString(File file) throws IOException {
        FileInputStream inputStream = new FileInputStream(file);
        BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream, "UTF-8"));
        StringBuilder text = new StringBuilder();

        String line;
        while( (line = reader.readLine()) != null) {
            text.append(line).append("\n");
        }
        inputStream.close();

        return text.toString();
    }
95447
public static void writePropertiesFile( Properties properties, File file ) throws IOException {

		OutputStream out = null;
		try {
			out = new FileOutputStream( file );
			properties.store( out, "" );

		} finally {
			closeQuietly( out );
		}
	}
531806
@Nonnull
    public static String readFile(@Nonnull File file, @Nonnull Charset charset) throws IOException {
        if (file == null)
            throw new NullPointerException("Given 'file' can not be null");
        if (!file.exists())
            throw new IllegalArgumentException("File " + file.getAbsolutePath() + " does not exist");
        if (file.isDirectory())
            throw new IllegalArgumentException("File " + file.getAbsolutePath() + " can NOT be a directory");

        InputStream in = new BufferedInputStream(new FileInputStream(file));
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        copy(in, bos);
        return new String(bos.toByteArray(), charset);

    }
681343
public static String getProperty(File file, String key) {
		return getProperty(file, key, null);
	}
1330936
public static LogFile get(PropertyResolver propertyResolver) {
		String file = getLogFileProperty(propertyResolver, FILE_NAME_PROPERTY,
				FILE_PROPERTY);
		String path = getLogFileProperty(propertyResolver, FILE_PATH_PROPERTY,
				PATH_PROPERTY);
		if (StringUtils.hasLength(file) || StringUtils.hasLength(path)) {
			return new LogFile(file, path);
		}
		return null;
	}
1074599
public static String fromFile(File file) throws IOException {
        BufferedReader br = new BufferedReader(new FileReader(file));
        StringBuilder sb = new StringBuilder();
        String line = br.readLine();

        while (line != null) {
            sb.append(line);
            line = br.readLine();
            if (line != null)
                sb.append(System.lineSeparator());
        }

        br.close();
        return sb.toString();
    }
745705
@NonNull
    private PropertiesMap read(@NonNull Context context, @NonNull String fileName) {
        InputStream in = null;
        try {
            in = context.getAssets().open(fileName);
            Properties props = new Properties();
            props.load(in);

            String name;
            for (String key : props.stringPropertyNames()) {
                name = key.toLowerCase(Locale.ENGLISH);
                map.put(name, props.getProperty(key));
            }
        } catch (Exception e) {
            Log.e(TAG, "Error reading properties file: " + fileName, e);
        } finally {
            if (in != null) {
                try {
                    in.close();
                } catch (Exception ignored) {
                }
            }
        }

        return this;
    }
706140
public static Properties loadProperties(String fileName) {
        LowerCaseProperties properties = new LowerCaseProperties();
        ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
        URL url = classLoader.getResource(fileName);

        // try opening from classpath
        if (url != null) {
            InputStream urlStream = null;
            try {
                urlStream = url.openStream();
                properties.load(urlStream);

                logger.info("Properties from classpath loaded file: " + fileName);
            } catch (IOException e) {
                logger.info("Properties from classpath not loaded because file not found: " + fileName);
            } finally {
                if (urlStream != null) {
                    try {
                        urlStream.close();
                    } catch (IOException e) {
                    }
                }
            }
        }

        // Override properties found on the classpath with any found in a file
        // of the same name
        LowerCaseProperties propertiesFromFileSystem = loadProperties(new File(fileName));
        properties.putAll(propertiesFromFileSystem);
        return properties;
    }
1020977
public Toml read(File file) {
    try {
      return read(new InputStreamReader(new FileInputStream(file), "UTF8"));
    } catch (Exception e) {
      throw new RuntimeException(e);
    }
  }
519048
public static Properties fromFile(
    final File file)
    throws IOException
  {
    Objects.requireNonNull(file, "File");

    try (InputStream stream = Files.newInputStream(file.toPath())) {
      final Properties p = new Properties();
      p.load(stream);
      return p;
    }
  }
476899
public static <MSG extends Message> MSG read(File file, Parser<MSG> parser) {
    InputStream input = null;
    try {
      input = new BufferedInputStream(new FileInputStream(file));
      return parser.parseFrom(input);
    } catch (Exception e) {
      throw ContextException.of("Unable to read message", e).addContext("file", file);
    } finally {
      IOUtils.closeQuietly(input);
    }
  }
1194931
static List<PatternLevel> readLevelResourceFile(InputStream stream) {
		List<PatternLevel> levels = null;
		if (stream != null) {
			try {
				levels = configureClassLevels(stream);
			} catch (IOException e) {
				System.err.println(
						"IO exception reading the log properties file '" + LOCAL_LOG_PROPERTIES_FILE + "': " + e);
			} finally {
				try {
					stream.close();
				} catch (IOException e) {
					// ignore close exception
				}
			}
		}
		return levels;
	}
393336
public Observable<File> copyLogs(@NonNull File file) {
        return state.get() > GlobalState.INITIALISING ? logMgr.copyLogs(file) : Observable.fromCallable(() -> null);
    }