var dicfile = "D:\\temp\\stop.txt"
for (word <- Source.fromFile(dicfile).getLines()) {
println(word)
}
报错:
Exception in thread "main" java.nio.charset.MalformedInputException: Input length = 1at java.nio.charset.CoderResult.throwException(CoderResult.java:277)
at sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:338)
at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:177)
解决:
将读取文件编码改成UTF-8