close InputStream and OutputStream - Android java.io

Android examples for java.io:InputStream

Description

close InputStream and OutputStream

Demo Code

import android.os.Environment;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.channels.FileChannel;

public class Main{

    public static void close(InputStream stream) {
        if (stream != null) {
            try {
                stream.close();//from   w  ww  . jav  a  2  s  .  c  om
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
    public static void close(OutputStream stream) {
        if (stream != null) {
            try {
                stream.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }

}

Related Tutorials