All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.sf.mmm.util.io.DevZero Maven / Gradle / Ivy

The newest version!
/* $Id: DevZero.java 380 2007-12-17 13:32:37Z hohwille $
 * Copyright (c) The m-m-m Team, Licensed under the Apache License, Version 2.0
 * http://www.apache.org/licenses/LICENSE-2.0 */
package net.sf.mmm.util.io;

import java.io.IOException;
import java.io.InputStream;

/**
 * This is an implementation of /dev/zero as {@link InputStream}.
 * In other words the {@link DevZero} is a dummy {@link InputStream} that
 * produces infinite zeros.
* ATTENTION:
* Please be careful NOT to cause infinity loops when using this class! * * @author Joerg Hohwiller (hohwille at users.sourceforge.net) */ public final class DevZero extends InputStream { /** The singleton instance. */ public static final DevZero INSTANCE = new DevZero(); /** * The constructor. */ private DevZero() { super(); } /** * {@inheritDoc} */ @Override public int read() throws IOException { return 0; } /** * {@inheritDoc} */ @Override public int read(byte[] b, int off, int len) { for (int i = off; i < len; i++) { b[i] = 0; } return len; } /** * {@inheritDoc} */ @Override public void close() { // do nothing... } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy