1/*
2 * Copyright (C) 2010 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package libcore.java.io;
18
19import java.io.ByteArrayOutputStream;
20import java.io.OutputStream;
21import java.io.PrintStream;
22import java.util.Locale;
23
24/**
25 * A PrintStream that throws away its output.
26 */
27public final class NullPrintStream extends PrintStream {
28    public NullPrintStream() {
29        // super class complains if argument is null
30        super((OutputStream) new ByteArrayOutputStream());
31    }
32    public boolean checkError() { return false; }
33    protected void clearError() {}
34    public void close() {}
35    public void flush() {}
36    public PrintStream format(String format, Object... args) { return this; }
37    public PrintStream format(Locale l, String format, Object... args) { return this; }
38    public PrintStream printf(String format, Object... args) { return this; }
39    public PrintStream printf(Locale l, String format, Object... args) { return this; }
40    public void print(char[] charArray) {}
41    public void print(char ch) {}
42    public void print(double dnum) {}
43    public void print(float fnum) {}
44    public void print(int inum) {}
45    public void print(long lnum) {}
46    public void print(Object obj) {}
47    public void print(String str) {}
48    public void print(boolean bool) {}
49    public void println() {}
50    public void println(char[] charArray) {}
51    public void println(char ch) {}
52    public void println(double dnum) {}
53    public void println(float fnum) {}
54    public void println(int inum) {}
55    public void println(long lnum) {}
56    public void println(Object obj) {}
57    public void println(String str) {}
58    public void println(boolean bool) {}
59    protected void setError() {}
60    public void write(byte[] buffer, int offset, int length) {}
61    public void write(int oneByte) {}
62    public PrintStream append(char c) { return this; }
63    public PrintStream append(CharSequence csq) { return this; }
64    public PrintStream append(CharSequence csq, int start, int end) { return this; }
65}
66