All Downloads are FREE. Search and download functionalities are using the official Maven repository.

dsh.sdk.internal.Conversion Maven / Gradle / Ivy

Go to download

The Data Serviceshub (DSH) Platform SDK facilitates easier development of applications on the DSH. It abstracts over the authentication and configuration of your Kafka clients against the policies of the DSH.

There is a newer version: 0.3.1
Show newest version
package dsh.sdk.internal;

import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

/**
 * General purpose conversion functions
 */
public class Conversion {

    /**
     * Convert a character stream to Java Properties
     *
     * @param s String representation of Properties
     * @return Properties
     * @exception IllegalArgumentException when the provided String can not be parsed as a list of Java Properties
     * @see Properties
     */
    public static Properties convertToProperties(String s) {
        try (InputStream propStream = new ByteArrayInputStream(s.getBytes())) {
            Properties props = new Properties();
            props.load(propStream);
            return props;
        } catch (IOException e) {
            throw new IllegalArgumentException("can not convert string to properties", e);
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy