Skip to content

Commit

Permalink
Merge pull request quarkusio#22160 from gastaldi/utf
Browse files Browse the repository at this point in the history
  • Loading branch information
gastaldi authored Dec 13, 2021
2 parents c7241e7 + 54d99cc commit cd56c83
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions docs/src/main/asciidoc/vertx.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,11 @@ Then, in the `VertxResource` file add the following method:

[source, java]
----
@GET // <1>
@GET // <1>
@Path("/lorem")
public Uni<String> readShortFile() { // <2>
return vertx.fileSystem().readFile("lorem.txt") // <3>
.onItem().transform(content -> content.toString("UTF-8")); // <4>
public Uni<String> readShortFile() { // <2>
return vertx.fileSystem().readFile("lorem.txt") // <3>
.onItem().transform(content -> content.toString(StandardCharsets.UTF_8)); // <4>
}
----
1. This endpoint handles HTTP `GET` request on path `/lorem` (so the full path will be `vertx/lorem`)
Expand Down Expand Up @@ -211,13 +211,13 @@ Add the following method to the `VertxResource` class:
----
@GET
@Path("/book")
public Multi<String> readLargeFile() { // <1>
return vertx.fileSystem().open("book.txt", // <2>
public Multi<String> readLargeFile() { // <1>
return vertx.fileSystem().open("book.txt", // <2>
new OpenOptions().setRead(true)
)
.onItem().transformToMulti(file -> file.toMulti()) // <3>
.onItem().transform(content -> content.toString("UTF-8") // <4>
+ "\n------------\n"); // <5>
.onItem().transformToMulti(file -> file.toMulti()) // <3>
.onItem().transform(content -> content.toString(StandardCharsets.UTF_8)) // <4>
+ "\n------------\n"); // <5>
}
----
1. This time, we return a Multi as we want to stream the chunks
Expand Down

0 comments on commit cd56c83

Please sign in to comment.