Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

closable resources java

try (Scanner scanner = new Scanner(new File("test.txt"))) {
    while (scanner.hasNext()) {
        System.out.println(scanner.nextLine());
    }
} catch (FileNotFoundException fnfe) {
    fnfe.printStackTrace();
}
Source by www.baeldung.com #
 
PREVIOUS NEXT
Tagged: #closable #resources #java
ADD COMMENT
Topic
Name
1+9 =