Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import java.io.ByteArrayInputStream;
import java.io.InputStream;

import java.util.HashMap;

import java.util.Map;

import java.util.Properties;

public class Main {
    public static Map<String, String> toMap(String properties) {
        try {
            InputStream is = new ByteArrayInputStream(properties.getBytes("UTF-8"));
            Properties prop = new Properties();
            prop.load(is);
            Map<String, String> ret = new HashMap<String, String>();
            for (String key : prop.stringPropertyNames()) {
                ret.put(key, prop.getProperty(key));
            }
            return ret;
        } catch (Exception ex) {
            ex.printStackTrace();
        }
        return null;
    }
}