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

net.sf.microlog.core.IOUtil Maven / Gradle / Ivy

The newest version!
package net.sf.microlog.core;

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

import javax.microedition.io.Connection;

/**
 * Some I/O utilities to be used in a Java ME CLDC environment.
 * 
 * @author Johan Karlsson
 *
 */
public class IOUtil {

	/**
	 * Close the InputStream silent.
	 * 
	 * @param inputStream
	 *            the InputStream to close.
	 */
	public static void closeSilent(InputStream inputStream) {
		if (inputStream != null) {
			try {
				inputStream.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
	}

	/**
	 * Close the OutputStream silent.
	 * 
	 * @param inputStream
	 *            the OutputStream to close.
	 */
	public static void closeSilent(OutputStream outputStream) {
		if (outputStream != null) {
			try {
				outputStream.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
	}

	/**
	 * Close the Connection silent.
	 * 
	 * @param connection
	 *            the Connection to close.
	 */
	public static void closeSilent(Connection connection) {
		if (connection != null) {
			try {
				connection.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy