A Scanner object may read a text file. Utilizing the methods included with the Scanner class is a benefit of utilizing the Scanner.
To guarantee that the file is closed, the application should define the Print Writer variable in a try-with-resources statement. Leading and trailing spaces are removed by the built-in Java String function trim(). The space character's Unicode value is "u0020." Java's trim() function looks for this Unicode value before and after the text, removes any spaces if they are present, and then returns the string that was omitted. The exception produced inside the try block will be propagated up the call stack if it occurs both inside the try-with-resources block and when a resource is closed (when close() is used).
Learn more about Unicode here-
https://brainly.com/question/17147612
#SPJ4