SkipNegative.java revision 3261
653N/A/*
653N/A * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved.
653N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
653N/A *
943N/A * This code is free software; you can redistribute it and/or modify it
653N/A * under the terms of the GNU General Public License version 2 only, as
653N/A * published by the Free Software Foundation.
919N/A *
919N/A * This code is distributed in the hope that it will be useful, but WITHOUT
919N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
919N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
919N/A * version 2 for more details (a copy is included in the LICENSE file that
919N/A * accompanied this code).
919N/A *
919N/A * You should have received a copy of the GNU General Public License version
919N/A * 2 along with this work; if not, write to the Free Software Foundation,
919N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
919N/A *
919N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
919N/A * or visit www.oracle.com if you need additional information or have any
919N/A * questions.
919N/A */
919N/A
919N/A/* @test
653N/A @bug 4150442
653N/A @summary Skip must throw an exception for negative args
653N/A*/
653N/A
653N/A
653N/A
970N/Aimport java.io.*;
970N/A
970N/Apublic class SkipNegative {
970N/A public static void main(String argv[]) throws Exception {
970N/A File f = new File(System.getProperty("test.src", "."),
970N/A "SkipInput.txt");
970N/A FileReader fr = new FileReader(f);
970N/A long nchars = -1L;
653N/A try {
911N/A long actual = fr.skip(nchars);
911N/A } catch(IllegalArgumentException e){
911N/A // Negative argument caught
911N/A return;
911N/A } finally {
653N/A fr.close();
653N/A }
653N/A throw new Exception("Skip should not accept negative values");
653N/A }
653N/A}
653N/A