< prev index next >

test/jdk/java/util/Scanner/FailingConstructors.java

Print this page

        

*** 1,7 **** /* ! * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. --- 1,7 ---- /* ! * Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation.
*** 21,40 **** * questions. */ /** * @test ! * @bug 7000511 * @summary PrintStream, PrintWriter, Formatter, Scanner leave files open when * exception thrown */ import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.nio.file.Files; import java.util.Scanner; public class FailingConstructors { static final String fileName = "FailingConstructorsTest"; --- 21,41 ---- * questions. */ /** * @test ! * @bug 7000511 8190577 * @summary PrintStream, PrintWriter, Formatter, Scanner leave files open when * exception thrown */ import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.FileNotFoundException; import java.io.IOException; + import java.nio.charset.Charset; import java.nio.file.Files; import java.util.Scanner; public class FailingConstructors { static final String fileName = "FailingConstructorsTest";
*** 63,73 **** } check(exists, file); try { ! new Scanner(file, null); fail(); } catch(FileNotFoundException|NullPointerException e) { pass(); } --- 64,81 ---- } check(exists, file); try { ! new Scanner(file, (String)null); ! fail(); ! } catch(FileNotFoundException|NullPointerException e) { ! pass(); ! } ! ! try { ! new Scanner(file, (Charset)null); fail(); } catch(FileNotFoundException|NullPointerException e) { pass(); }
*** 82,92 **** } check(exists, file); try { ! new Scanner(file.toPath(), null); fail(); } catch(FileNotFoundException|NullPointerException e) { pass(); } --- 90,107 ---- } check(exists, file); try { ! new Scanner(file.toPath(), (String)null); ! fail(); ! } catch(FileNotFoundException|NullPointerException e) { ! pass(); ! } ! ! try { ! new Scanner(file.toPath(), (Charset)null); fail(); } catch(FileNotFoundException|NullPointerException e) { pass(); }
< prev index next >