Here you can find the source of loadEscaping(Properties prop, InputStream stream)
Parameter | Description |
---|---|
prop | properties object |
stream | the stream |
Parameter | Description |
---|---|
IOException | if a read error occurs |
private static void loadEscaping(Properties prop, InputStream stream) throws IOException
//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); } } } }