Given a file and we have to read a Boolean value from the file.
What is Boolean value?
The word Boolean (which is a data type and class both in Java) can be represent by either True or False.
Here, we are creating an object scan of Scanner class by passing object of "File" class, which is initializing with the file name.
The method hasNextLine() is using to check whether data is available in the file or not, if method returns "True" then we are reading byte using scan.nextBoolean() and printing on the console.
Consider the program:
Output
Note: File "Boolean.txt" contains "nerdutella".
need an explanation for this answer? contact us directly to get an explanation for this answer