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

org.aktin.broker.client.Utils Maven / Gradle / Ivy

Go to download

Broker client library. This library can be used to retrieve queries from a broker, request/submit status information and submit query results.

The newest version!
package org.aktin.broker.client;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.nio.charset.Charset;

public class Utils {

	public static BufferedReader contentReaderForInputStream(InputStream in, String contentType, Charset defaultCharset) throws UnsupportedEncodingException, IOException{
		// default HTTP charset
		Charset charset = defaultCharset;
		// use charset from content-type header
		if( contentType != null ) {
			int csi = contentType.indexOf("charset=");
			if( csi != -1 ){
				charset = Charset.forName(contentType.substring(csi+8));
			}			
		}
		return new BufferedReader(new InputStreamReader(in, charset));
	}

	public static final String toHexString(byte[] bytes) {
		StringBuilder b = new StringBuilder(16*2);
		for( int i=0; i




© 2015 - 2024 Weber Informatics LLC | Privacy Policy