Java Properties Load from File loadEscaping(Properties prop, InputStream stream)

Here you can find the source of loadEscaping(Properties prop, InputStream stream)

Description

Loads the given properties from the given input stream.

License

Open Source License

Parameter

Parameter Description
prop properties object
stream the stream

Exception

Parameter Description
IOException if a read error occurs

Declaration

private static void loadEscaping(Properties prop, InputStream stream)
        throws IOException 

Method Source Code

//package com.java2s;
/*//  w  w  w.  j  a  v  a  2s .com
 * $Id$
 *
 * Copyright (c) 2004-2005 by the TeXlapse Team.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 */

import java.io.ByteArrayOutputStream;

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

import java.util.Properties;
import java.util.StringTokenizer;

public class Main {
    /**
     * Loads the given properties from the given input stream.
     * @param prop properties object
     * @param stream the stream
     * @throws IOException if a read error occurs
     */
    private static void loadEscaping(Properties prop, InputStream stream)
            throws IOException {

        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        while (true) {
            int b = stream.read();
            if (b == -1) {
                break;
            } else if (b == '\\') {
                // write extra backslash to escape them
                //bos.write('\\');
            }

            bos.write(b);
        }

        StringTokenizer st = new StringTokenizer(bos.toString(), "\r\n");
        while (st.hasMoreTokens()) {
            String token = st.nextToken();
            int index = token.indexOf('=');
            if (index > 0) {
                String key = token.substring(0, index);
                String value = token.substring(index + 1);
                prop.setProperty(key, value);
            }
        }
    }
}

Related

  1. loadDefaultConfiguration()
  2. loadDefaultProps(Properties deployProps)
  3. LoadDeployedObjects(String outputDirectory)
  4. loadEnv(final String configFilePath)
  5. loadErrorMap(InputStream resourceStream)
  6. loadFixedCommits()
  7. loadFixture(String fixtureId)
  8. loadGradleResource(String fileName)
  9. loadHeader(String fileName)