Java Properties Load from File loadInputAsString(InputStream is)

Here you can find the source of loadInputAsString(InputStream is)

Description

Something really straight forward to read the content of the file.

License

Open Source License

Declaration

public static String loadInputAsString(InputStream is) 

Method Source Code


//package com.java2s;
// are made available under the terms of the Eclipse Public License v1.0

import java.io.BufferedReader;

import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;

public class Main {
    /**//ww w  . j  a  v  a2 s.  co  m
     * Something really straight forward to read the content of the file.
     * It is just jetty.xml: no need to be really fast and optimized here.
     */
    public static String loadInputAsString(InputStream is) {
        StringBuilder sb = new StringBuilder();
        try {
            BufferedReader reader = new BufferedReader(new InputStreamReader(is, "UTF-8")); //$NON-NLS-1$
            String newline = System.getProperty("line.separator"); //$NON-NLS-1$
            String line = null;
            while ((line = reader.readLine()) != null) {
                sb.append(line + newline);
            }
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                is.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

        return sb.toString();
    }
}

Related

  1. loadFixedCommits()
  2. loadFixture(String fixtureId)
  3. loadGradleResource(String fileName)
  4. loadHeader(String fileName)
  5. loadIncludes(String propertyName, boolean mandatory, File file, Properties configProps)
  6. loadInstallProps()
  7. loadJZ(File file)
  8. loadKeys(String propertiesFileName, InputStream in)
  9. loadLibrary(String libFileName)