(byte[] data, Charset charset, String defaultValue)
| 283 | } |
| 284 | |
| 285 | public static String decodeOrDefault(byte[] data, Charset charset, String defaultValue) { |
| 286 | if (data == null) { |
| 287 | return defaultValue; |
| 288 | } |
| 289 | checkNotNull(charset, "charset"); |
| 290 | try { |
| 291 | return charset.newDecoder().decode(ByteBuffer.wrap(data)).toString(); |
| 292 | } catch (CharacterCodingException ex) { |
| 293 | return defaultValue; |
| 294 | } |
| 295 | } |
| 296 | |
| 297 | /** |
| 298 | * If the provided String is not null or empty. |
no test coverage detected