user9449907 :
Sonar complains that the Scanner should always be closed, is it right?
Scanner scanner = new Scanner("simple string")
This scanner is not scanning from file etc. Why should it be closed?
Murat Karagöz :
By calling new Scanner("string")
it creates a StringReader
which creates a character stream. So you have to close it.
public Scanner(String source) {
this(new StringReader(source), WHITESPACE_PATTERN);
}