public static String detectEncoding(byte[] data, String defaultEncoding) {
		CharsetDetector detector = new CharsetDetector();
		detector.setText(data);
		CharsetMatch cm = detector.detect();
		String estimatedEncoding = cm.getName();
		boolean isReliable = Charset.isSupported(estimatedEncoding) && cm.getConfidence() >= MINIMAL_CONFIDENCE_LEVEL;
		return isReliable ? estimatedEncoding : defaultEncoding;
	}
Detect encoding of given data.

@param data            byte array
@param defaultEncoding the default encoding if no encoding is sure.
@return encoding name detected encoding name
ngrinder-controller/src/main/java/org/ngrinder/common/util/PropertyUtils.java