View Javadoc
1   /*
2    * Copyright (C) 2009-2010, Google Inc. and others
3    *
4    * This program and the accompanying materials are made available under the
5    * terms of the Eclipse Distribution License v. 1.0 which is available at
6    * https://www.eclipse.org/org/documents/edl-v10.php.
7    *
8    * SPDX-License-Identifier: BSD-3-Clause
9    */
10  
11  package org.eclipse.jgit.util.io;
12  
13  import java.io.IOException;
14  import java.io.OutputStream;
15  
16  import org.eclipse.jgit.internal.JGitText;
17  
18  /**
19   * An OutputStream which always throws IllegalStateExeption during write.
20   */
21  public final class DisabledOutputStream extends OutputStream {
22  	/** The canonical instance which always throws IllegalStateException. */
23  	public static final DisabledOutputStream INSTANCE = new DisabledOutputStream();
24  
25  	private DisabledOutputStream() {
26  		// Do nothing, but we want to hide our constructor to prevent
27  		// more than one instance from being created.
28  	}
29  
30  	/** {@inheritDoc} */
31  	@Override
32  	public void write(int b) throws IOException {
33  		// We shouldn't be writing output at this stage, there
34  		// is nobody listening to us.
35  		//
36  		throw new IllegalStateException(JGitText.get().writingNotPermitted);
37  	}
38  }