close scanner java

Java
Scanner scanner = new Scanner("Hello world");

//do something with scanner

scanner.close();

Source

Also in Java: