I'm new to Scala and would like to use scala.io.Source
class. But I found out that it operates with Char
s, but not Byte
s. The thing that I'm confused about is that Char
s are encoding/platform dependent. I mean we can have characters encoded in UTF-8
or "windows-1251".
windows-1251
is strictly 1-byte encoding... Is there a way to operate with raw bytes?
If you want to read Char
as windows-1251
, you can do it like:
scala.io.Source.fromFile(myFile, "windows-1251")
set encoding for this read.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.