public static String
formatString(byte [] b, int lineLength, String prefix, boolean addClose) {
	String s = toString(b);
	StringBuffer sb = new StringBuffer();
	for (int i = 0; i < s.length(); i += lineLength) {
		sb.append (prefix);
		if (i + lineLength >= s.length()) {
			sb.append(s.substring(i));
			if (addClose)
				sb.append(" )");
		}
		else {
			sb.append(s.substring(i, i + lineLength));
			sb.append("\n");
		}
	}
	return sb.toString();
}
public static String formatString ( byte [ ] b , int lineLength , String prefix , boolean addClose ) { String s = toString ( b ) ; StringBuffer sb = new StringBuffer ( ) ; for ( int i = 0 ; i < s . length ( ) ; i += lineLength ) { sb . append ( prefix ) ; if ( i + lineLength >= s . length ( ) ) { sb . append ( s . substring ( i ) ) ; if ( addClose ) sb . append ( " )" ) ; } else { sb . append ( s . substring ( i , i + lineLength ) ) ; sb . append ( "\n" ) ; } } return sb . toString ( ) ; }
Formats data into a nicely formatted base64 encoded String
@param b An array containing binary data
@param lineLength The number of characters per line
@param prefix A string prefixing the characters on each line
@param addClose Whether to add a close parenthesis or not
@return A String representing the formatted output