Examples

Page 15 of 50

Browse code examples

javaSnippet

Default Charset Is UTF-8

Confirm that Charset.defaultCharset is UTF-8 since JDK 18 regardless of platform, so charset-less getBytes and new String behave identically everywhere.

javaSnippet

ShutdownNow Drains Queued Tasks

Call shutdownNow on a busy single-thread executor to interrupt the running task and drain the queue: it returns the runnables that never commenced.

javaSnippet

UTF-8 BOM Survives readString

Java UTF-8 decoding does not strip the BOM, so Files.readString on an Excel-style export starts with U+FEFF and header matches silently fail.

javaSnippet

Zip FS Writes Archive Entries

Mount a ZIP via the zipfs provider with a jar: URI and create=true, create parent directories explicitly, then read and write entries with the Files API.