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