PDF FILE IN A BROWSER: java.nio.charset.MalformedInputException: Input length = 1

I’m trying to display a PDF FILE in an internet browser, but “MalformedInputException: Input length = 1” comes. I don’t undertsand how to do it. With a XML FILE it woks.

My code:

ruta

controlador

why are you calling mkString?

You cannot use mkString, because the content does not decode to a String. Instead, get an Array[Byte] or directly write from the Source to a File. Also, new File(generatedFile) looks wrong, because new File(String) expects a file name, not file content. To write to a java.io.File, open a FileOutputStream to it. Consider using java.nio.

Thank you for yor answer.

I don’t knoy how: “To write to a java.io.File, open a FileOutputStream to it”

I have done several tests, but I always find syntax problems.

Sorry, I’m new in Scala

TIA,

AUGUSTO