View Javadoc
1   /*
2    * Copyright (C) 2011, Stefan Lay <stefan.lay@.com> 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  package org.eclipse.jgit.util.io;
11  
12  import java.io.OutputStream;
13  
14  /**
15   * An OutputStream which ignores everything written to it.
16   */
17  public class NullOutputStream extends OutputStream {
18  
19  	/** The canonical instance. */
20  	public static final NullOutputStreamream.html#NullOutputStream">NullOutputStream INSTANCE = new NullOutputStream();
21  
22  	private NullOutputStream() {
23  		// Do nothing, but we want to hide our constructor to prevent
24  		// more than one instance from being created.
25  	}
26  
27  	/** {@inheritDoc} */
28  	@Override
29  	public void write(int b) {
30  		// Discard.
31  	}
32  
33  	/** {@inheritDoc} */
34  	@Override
35  	public void write(byte[] buf) {
36  		// Discard.
37  	}
38  
39  	/** {@inheritDoc} */
40  	@Override
41  	public void write(byte[] buf, int pos, int cnt) {
42  		// Discard.
43  	}
44  }