0

I made a get in my javalin that sends back data from a text file.

this is the get method:

app.get("/info", ctx -> {

            // stream, streamReader en buffer om file uit te lezen
            FileInputStream fileInputStream = new FileInputStream("wedstrijd.txt");
            InputStreamReader inputStreamReader = new InputStreamReader(fileInputStream, StandardCharsets.UTF_8);
            BufferedReader reader = new BufferedReader(inputStreamReader);

            // geef alle regels van de file terug
            ctx.result(reader.lines().collect(Collectors.joining()));
        });

But this gives back the data in one big line of text.

How can I format this text to make it look a bit better?

Ronny Giezen
  • 557
  • 2
  • 10
  • 21
  • Can you clarify what you mean by "better"? You can edit the question to show a sample of what you have, and a sample of what you want. – andrewJames Jun 14 '20 at 21:38

1 Answers1

0

Maybe try adding a line break at the in your ctx.result(reader.lines().collect(Collectors.joining())); line, like this

ctx.result(reader.lines().collect(Collectors.joining()) + "\n");

You can also refer to this question: Add new line to bottom of StringJoiner

sabraship
  • 99
  • 1
  • 8