Welcome to the Ranch
I don't think you can detect encoding with a Scanner. You can instruct a Scanner to use a particular encoding with its
constructors, and some of the better‑known encoding are specified in the
Charset class, but I do not think you can instruct a Scanner to detect an encoding from the input. You can read more about encodings written by
Joel Spolsky.