cookbook:javacodepieces
获取回调函数中的值
AtomicReference<String> body = new AtomicReference<>();
client.call(
request,
response -> {
try {
body.set(new String(response.body().readAllBytes(), Charset.defaultCharset()));
} catch (IOException ex) {
throw new RuntimeException(ex);
}
},
new RequestOptions()
.setUrl("https://yaocheng.cn/cat/add")
.setTimeout(Duration.of(1L, ChronoUnit.SECONDS)));
cookbook/javacodepieces.txt · 最后更改: 2021/10/22 17:16 由 plough