001 /* 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017 package org.apache.commons.io.output; 018 019 import java.io.Writer; 020 021 /** 022 * This {@link Writer} writes all data to the famous <b>/dev/null</b>. 023 * <p> 024 * This <code>Writer</code> has no destination (file/socket etc.) and all 025 * characters written to it are ignored and lost. 026 * 027 * @version $Id: NullWriter.java 610010 2008-01-08 14:50:59Z niallp $ 028 */ 029 public class NullWriter extends Writer { 030 031 /** 032 * A singleton. 033 */ 034 public static final NullWriter NULL_WRITER = new NullWriter(); 035 036 /** 037 * Constructs a new NullWriter. 038 */ 039 public NullWriter() { 040 } 041 042 /** 043 * Does nothing - output to <code>/dev/null</code>. 044 * @param idx The character to write 045 */ 046 public void write(int idx) { 047 //to /dev/null 048 } 049 050 /** 051 * Does nothing - output to <code>/dev/null</code>. 052 * @param chr The characters to write 053 */ 054 public void write(char[] chr) { 055 //to /dev/null 056 } 057 058 /** 059 * Does nothing - output to <code>/dev/null</code>. 060 * @param chr The characters to write 061 * @param st The start offset 062 * @param end The number of characters to write 063 */ 064 public void write(char[] chr, int st, int end) { 065 //to /dev/null 066 } 067 068 /** 069 * Does nothing - output to <code>/dev/null</code>. 070 * @param str The string to write 071 */ 072 public void write(String str) { 073 //to /dev/null 074 } 075 076 /** 077 * Does nothing - output to <code>/dev/null</code>. 078 * @param str The string to write 079 * @param st The start offset 080 * @param end The number of characters to write 081 */ 082 public void write(String str, int st, int end) { 083 //to /dev/null 084 } 085 086 /** @see java.io.Writer#flush() */ 087 public void flush() { 088 //to /dev/null 089 } 090 091 /** @see java.io.Writer#close() */ 092 public void close() { 093 //to /dev/null 094 } 095 096 }