FIND YOUR NEXT FEW LINES

Results for “Java”

Small, practical examples. Search by task or narrow things down below.

257 snippets foundClear filters
JavaFile operations & binary data

Create and clean up a temporary file

Java: Create a unique file and remove it in finally even when the operation fails.

Java✓ Tested
JavaScriptArray restructuring

Create independent rows in a matrix

JavaScript: Use a mapping function to create each row instead of sharing one array with fill.

JavaScript✓ Tested
JavaFiles & paths

Create nested directories

Create missing parent directories with Java Files.createDirectories.

Java✓ Tested
JavaEncoding & structured values

Decode a form query parameter

Java: URLDecoder reverses form encoding and treats plus as a space.

Java✓ Tested
JavaScriptRegular expressions & URL encoding

Decode a percent-encoded URL component

JavaScript: decodeURIComponent reverses percent encoding and throws for malformed sequences.

JavaScript✓ Tested
JavaRecords & reliable control flow

Define an immutable data record

Java: A local record gives a small Java data carrier named accessors and value semantics.

Java✓ Tested
JavaScriptPromises & iteration protocols

Delegate iteration to another iterable

JavaScript: yield-star forwards items from another iterable while retaining generator composition.

JavaScript✓ Tested
JavaFile operations & binary data

Delete a known temporary file if present

Java: deleteIfExists returns whether a file was removed and still reports other I/O errors.

Java✓ Tested
JavaScriptUTC date operations

Detect an invalid Date object

JavaScript: An invalid Date has a NaN time value.

JavaScript✓ Tested
JavaPrecise numeric calculations

Detect integer addition overflow

Java: Math.addExact throws rather than silently wrapping on overflow.

Java✓ Tested
JavaScriptNumbers & numeric validation

Detect NaN without converting the input

JavaScript: Number.isNaN tests the special numeric value instead of applying string-to-number conversion.

JavaScript✓ Tested
JavaScriptNumbers & numeric validation

Display a number with a fixed decimal width

JavaScript: toFixed returns a formatted string rather than a numeric value.

JavaScript✓ Tested