Loading…
Loading…
Language
Articles and problems tagged Java.
Use HttpClient asynchronously: sendAsync and CompletableFuture pipelines, running many requests in parallel, combining and timing out futures, executors, HTTP/2 and HTTP/3 (Java 26) version negotiation, and the WebSocket API with listeners, fragments, pings and closing.
Use java.net.http.HttpClient for synchronous HTTP: building and closing clients, HttpRequest builders with methods, headers and timeouts, body publishers for strings, files, forms and multipart, body handlers for strings, lines, streams, files and size limits, headers, redirects and errors.
Send data to web servers with HttpURLConnection: query strings and URLEncoder/URLDecoder, POST with setDoOutput, form and JSON content types, Content-Length and streaming modes, error streams, automatic and manual redirects, cookies with CookieManager, and building multipart/form-data uploads.
Web addresses and resource fetching: URI syntax, resolving, relativizing, normalizing and encoding, why URL constructors are deprecated, openStream, URLConnection and HttpURLConnection, request and response headers, conditional requests, Basic authentication, file: and jar: URLs.
Cancel blocked network operations and secure connections: why interrupt doesn't unblock a Socket on a platform thread, SocketChannel and ClosedByInterruptException, virtual threads, then TLS with SSLSocket and SSLServerSocket, certificates, keystores, trust stores and SSLContext.
Write TCP servers in Java: ServerSocket, binding and backlog, the accept loop, an echo server, serving many clients concurrently with one virtual thread per connection, half-closing a connection with shutdownOutput, and shutting a server down cleanly.
Connect to network services from Java: ports and TCP connections, experimenting with telnet and netcat, Socket with input and output streams, connect and read timeouts, ConnectException, InetAddress and InetSocketAddress, address literals with ofLiteral, and a glimpse of UDP.
Turn XML into HTML, text or other XML with XSLT 1.0 from Java: templates and match patterns, apply-templates, value-of, for-each, sort, if and choose, variables and parameters, Templates and Transformer, Source and Result types, a flat file as SAX events, and secure settings.
Produce correct XML from Java: build DOM trees with createElement(NS), setAttribute(NS) and text, CDATA and comment nodes, serialize them with the identity Transformer and output properties or LSSerializer, and stream XML directly with XMLStreamWriter, including namespaces and escaping.
Process large XML documents without building a tree: SAX callbacks with DefaultHandler, startElement, characters and endElement, StAX pull parsing with XMLStreamReader and XMLEventReader, getElementText, skipping subtrees, filters, factory properties and safe settings.
How XML namespaces keep element names apart: namespace URIs, xmlns prefixes and default namespaces, scoping and attributes, namespace-aware DOM parsing with newNSInstance, getNamespaceURI and getLocalName, getElementsByTagNameNS, and XPath with a NamespaceContext.
Locate data in XML with XPath 1.0 from Java: location paths, // and predicates, attributes, axes, unions, functions like count, sum, contains and normalize-space, typed results with evaluateExpression and XPathNodes, compiled expressions, variables against injection, and errors.
Validate XML against an XML Schema (XSD) in Java: simple and complex types, restrictions with enumerations and patterns, sequence, choice, groups, occurrence limits, attribute defaults, SchemaFactory, Validator and setSchema, plus a config file that builds objects.
Describe and check XML structure with a DTD: internal and external DOCTYPE declarations, element content rules, #PCDATA and mixed content, ATTLIST types and defaults, ID and IDREF, entities, validating DOM parsers that drop whitespace, error handlers, and XML catalogs.
Read XML into a DOM tree with DocumentBuilderFactory and DocumentBuilder, walk Node, Element, Text and Attr objects, cope with whitespace text nodes, search with getElementsByTagName, and parse untrusted XML safely against XXE and entity-expansion attacks.
What XML is and how a document is built: the prolog and root element, elements, attributes and text, when to prefer elements over attributes, entity and character references, CDATA, comments and processing instructions, the well-formedness rules, and Java's XML APIs.
Split and rewrite text with Java regular expressions: split limits and empty strings, splitAsStream, splitWithDelimiters, Scanner delimiters, replaceAll with $n and ${name}, quoteReplacement, replacement functions, appendReplacement, and every Pattern flag with its inline form.
Put Java regular expressions to work with Pattern and Matcher: matches, lookingAt and find, predicates for streams, iterating with find and results(), Scanner.findAll, numbered and named groups, namedGroups, MatchResult snapshots, regions and \G.
The java.util.regex pattern language: literals and metacharacters, character classes with ranges, negation and intersection, \d \w \s and Unicode \p{...} classes, greedy, reluctant and possessive quantifiers, groups and back-references, boundaries, lookaround, and escaping.
Keep serialized Java objects correct over time and safe: readResolve and writeReplace with the serialization proxy pattern, serialVersionUID and serialver, how fields are matched between versions, ObjectInputValidation, deserialization filters, and deep copying by serialization.