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

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

/* 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.api;

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

/**
 * This is an implementation of {@code /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) * @since 1.0.0 */ public final class DevZero extends InputStream { /** The singleton instance. */ public static final DevZero INSTANCE = new DevZero(); /** * The constructor. */ private DevZero() { super(); } @Override public int read() throws IOException { return 0; } @Override public int read(byte[] b, int off, int len) { for (int i = off; i < len; i++) { b[i] = 0; } return len; } @Override public void close() { // do nothing... } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy