Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2009, 2010 Cloudsmith Inc. and others.
 * 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
 *
 * Contributors:
 *     Cloudsmith Inc. - initial API and implementation
 *******************************************************************************/

import java.io.*;

import java.util.*;

public class Main {
    /**
     * Stores the properties using {@link Properties#store(OutputStream, String)} on the given <code>stream</code>.
     * @param properties The properties to store
     * @param stream The stream to store to
     * @param comment The comment to use
     * @throws IOException
     */
    public static void storeProperties(Map<String, String> properties, OutputStream stream, String comment)
            throws IOException {
        Properties props = new Properties();
        props.putAll(properties);
        props.store(stream, comment);
    }

    /**
     * Copies all elements from <code>properties</code> into the given <code>result</code>.
     * @param properties
     * @param result
     */
    public static void putAll(Properties properties, Map<String, String> result) {
        for (Enumeration<Object> keys = properties.keys(); keys.hasMoreElements();) {
            String key = (String) keys.nextElement();
            result.put(key, properties.getProperty(key));
        }
    }
}