NhacVibe
Ảnh bìa Java : Files, HTTP and JSON

Java : Files, HTTP and JSON

Oddly Yogi · 6 lượt xem · 13 thg 11, 2026

Mô tả

Real programs keep data in files and talk to other services. In this video the Shelf library app learns both. Like an inter-library loan form that two libraries agree on, JSON gives programs a shared format. We work with paths and files using java.nio.file: Path, Files.writeString, readString, readAllLines, lines, walk, appending and NoSuchFileException. Then we export and import the catalogue as JSON with Jackson 3, map JSON into records, read lists with TypeReference, rename fields with @JsonProperty, and test it all with JUnit's @TempDir. Finally we start a small partner library server with the JDK's built-in HttpServer, call it with curl, and write a client with java.net.http.HttpClient: GET and POST requests, status codes, timeouts and sendAsync.

Versions: Java 25 LTS (Eclipse Temurin 25.0.5), Apache Maven 3.10.0, Jackson 3.3.0, JUnit 6.1.3.

In this chapter:
00:00 An inter-library loan form
01:31 Paths and writing files
03:26 Reading, listing and missing files
05:07 JSON with Jackson
07:37 Testing with @TempDir
09:27 A partner library server
11:11 Talking to the server with curl
13:04 An HTTP client in Java
15:51 Shelf meets the partner
18:36 Wrap up

This is Chapter 14 of 15 in the "Java" series.
#Java #Java25 #JSON #HttpClient #LearnJava