I'm using this code to read a resource:
val source = Source.fromResource(pathWithoutSlash)
val lines:Seq[String] = (for (l <- source.getLines() if ! l.trim.isEmpty) yield l.trim).toList
This code works fine when I run it locally - but on the server, it fails with:
Exception in thread "main" java.nio.charset.MalformedInputException: Input length = 1
at java.base/java.nio.charset.CoderResult.throwException(CoderResult.java:274)
at java.base/sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:339)
at java.base/sun.nio.cs.StreamDecoder.read(StreamDecoder.java:178)
at java.base/java.io.InputStreamReader.read(InputStreamReader.java:185)
at java.base/java.io.BufferedReader.fill(BufferedReader.java:161)
at java.base/java.io.BufferedReader.readLine(BufferedReader.java:326)
at java.base/java.io.BufferedReader.readLine(BufferedReader.java:392)
at scala.io.BufferedSource$BufferedLineIterator.hasNext(BufferedSource.scala:70)
I'm guessing its because the file does contain some accented characters, like: éclair's
, and probably the default charset being used on the server is different from what I have locally.
My question is, how can I change the charset on the server so it matches whatever I have locally (and how can I check what I have locally)?
Thanks.