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
(byte [] b, int lineLength, String prefix, boolean addClose)
| 67 | * @return A String representing the formatted output |
| 68 | */ |
| 69 | public static String |
| 70 | formatString(byte [] b, int lineLength, String prefix, boolean addClose) { |
| 71 | String s = toString(b); |
| 72 | StringBuffer sb = new StringBuffer(); |
| 73 | for (int i = 0; i < s.length(); i += lineLength) { |
| 74 | sb.append (prefix); |
| 75 | if (i + lineLength >= s.length()) { |
| 76 | sb.append(s.substring(i)); |
| 77 | if (addClose) |
| 78 | sb.append(" )"); |
| 79 | } |
| 80 | else { |
| 81 | sb.append(s.substring(i, i + lineLength)); |
| 82 | sb.append("\n"); |
| 83 | } |
| 84 | } |
| 85 | return sb.toString(); |
| 86 | } |
| 87 | |
| 88 | |
| 89 | /** |
no test coverage detected