java8-to-25: fix the Base64 replacement (sun.misc wraps with a bare newline) and add the wrapping probe

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017ic4b6vDJ5fWY5uEZaJFNi
This commit is contained in:
Claude
2026-12-03 23:46:26 +05:30
parent 94f8a0e003
commit 9d05be0c2c
5 changed files with 44 additions and 2 deletions
@@ -3,8 +3,8 @@ package com.ankurm.fixed;
import java.util.Base64;
public final class Tokens {
/** getMimeEncoder() wraps at 76 characters like sun.misc did; getEncoder() does not wrap. */
/** sun.misc wrapped lines at 76 characters with a bare '\n'; see probes/base64/Wrap.java. */
public static String encode(byte[] raw) {
return Base64.getMimeEncoder().encodeToString(raw);
return Base64.getMimeEncoder(76, new byte[] {'\n'}).encodeToString(raw);
}
}