1bc47398187c6ffd132435e51d8d61e6ec79a79dbPaul Westbrook/* 2bc47398187c6ffd132435e51d8d61e6ec79a79dbPaul Westbrook * Licensed to the Apache Software Foundation (ASF) under one or more 3bc47398187c6ffd132435e51d8d61e6ec79a79dbPaul Westbrook * contributor license agreements. See the NOTICE file distributed with 4bc47398187c6ffd132435e51d8d61e6ec79a79dbPaul Westbrook * this work for additional information regarding copyright ownership. 5bc47398187c6ffd132435e51d8d61e6ec79a79dbPaul Westbrook * The ASF licenses this file to You under the Apache License, Version 2.0 6bc47398187c6ffd132435e51d8d61e6ec79a79dbPaul Westbrook * (the "License"); you may not use this file except in compliance with 7bc47398187c6ffd132435e51d8d61e6ec79a79dbPaul Westbrook * the License. You may obtain a copy of the License at 8bc47398187c6ffd132435e51d8d61e6ec79a79dbPaul Westbrook * 9bc47398187c6ffd132435e51d8d61e6ec79a79dbPaul Westbrook * http://www.apache.org/licenses/LICENSE-2.0 10bc47398187c6ffd132435e51d8d61e6ec79a79dbPaul Westbrook * 11bc47398187c6ffd132435e51d8d61e6ec79a79dbPaul Westbrook * Unless required by applicable law or agreed to in writing, software 12bc47398187c6ffd132435e51d8d61e6ec79a79dbPaul Westbrook * distributed under the License is distributed on an "AS IS" BASIS, 13bc47398187c6ffd132435e51d8d61e6ec79a79dbPaul Westbrook * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14bc47398187c6ffd132435e51d8d61e6ec79a79dbPaul Westbrook * See the License for the specific language governing permissions and 15bc47398187c6ffd132435e51d8d61e6ec79a79dbPaul Westbrook * limitations under the License. 16bc47398187c6ffd132435e51d8d61e6ec79a79dbPaul Westbrook */ 17bc47398187c6ffd132435e51d8d61e6ec79a79dbPaul Westbrookpackage org.apache.commons.io.input; 18bc47398187c6ffd132435e51d8d61e6ec79a79dbPaul Westbrook 19bc47398187c6ffd132435e51d8d61e6ec79a79dbPaul Westbrookimport java.io.InputStream; 20bc47398187c6ffd132435e51d8d61e6ec79a79dbPaul Westbrook 21bc47398187c6ffd132435e51d8d61e6ec79a79dbPaul Westbrook/** 22bc47398187c6ffd132435e51d8d61e6ec79a79dbPaul Westbrook * Closed input stream. This stream returns -1 to all attempts to read 23bc47398187c6ffd132435e51d8d61e6ec79a79dbPaul Westbrook * something from the stream. 24bc47398187c6ffd132435e51d8d61e6ec79a79dbPaul Westbrook * <p> 25bc47398187c6ffd132435e51d8d61e6ec79a79dbPaul Westbrook * Typically uses of this class include testing for corner cases in methods 26bc47398187c6ffd132435e51d8d61e6ec79a79dbPaul Westbrook * that accept input streams and acting as a sentinel value instead of a 27bc47398187c6ffd132435e51d8d61e6ec79a79dbPaul Westbrook * <code>null</code> input stream. 28bc47398187c6ffd132435e51d8d61e6ec79a79dbPaul Westbrook * 29bc47398187c6ffd132435e51d8d61e6ec79a79dbPaul Westbrook * @version $Id: ClosedInputStream.java 601751 2007-12-06 14:55:45Z niallp $ 30bc47398187c6ffd132435e51d8d61e6ec79a79dbPaul Westbrook * @since Commons IO 1.4 31bc47398187c6ffd132435e51d8d61e6ec79a79dbPaul Westbrook */ 32bc47398187c6ffd132435e51d8d61e6ec79a79dbPaul Westbrookpublic class ClosedInputStream extends InputStream { 33bc47398187c6ffd132435e51d8d61e6ec79a79dbPaul Westbrook 34bc47398187c6ffd132435e51d8d61e6ec79a79dbPaul Westbrook /** 35bc47398187c6ffd132435e51d8d61e6ec79a79dbPaul Westbrook * A singleton. 36bc47398187c6ffd132435e51d8d61e6ec79a79dbPaul Westbrook */ 37bc47398187c6ffd132435e51d8d61e6ec79a79dbPaul Westbrook public static final ClosedInputStream CLOSED_INPUT_STREAM = new ClosedInputStream(); 38bc47398187c6ffd132435e51d8d61e6ec79a79dbPaul Westbrook 39bc47398187c6ffd132435e51d8d61e6ec79a79dbPaul Westbrook /** 40bc47398187c6ffd132435e51d8d61e6ec79a79dbPaul Westbrook * Returns -1 to indicate that the stream is closed. 41bc47398187c6ffd132435e51d8d61e6ec79a79dbPaul Westbrook * 42bc47398187c6ffd132435e51d8d61e6ec79a79dbPaul Westbrook * @return always -1 43bc47398187c6ffd132435e51d8d61e6ec79a79dbPaul Westbrook */ 44bc47398187c6ffd132435e51d8d61e6ec79a79dbPaul Westbrook public int read() { 45bc47398187c6ffd132435e51d8d61e6ec79a79dbPaul Westbrook return -1; 46bc47398187c6ffd132435e51d8d61e6ec79a79dbPaul Westbrook } 47bc47398187c6ffd132435e51d8d61e6ec79a79dbPaul Westbrook 48bc47398187c6ffd132435e51d8d61e6ec79a79dbPaul Westbrook} 49