Java Stream Close closeStream(FileInputStream in)

Here you can find the source of closeStream(FileInputStream in)

Description

close Stream

License

Apache License

Declaration

public static final void closeStream(FileInputStream in) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.io.*;

public class Main {

    public static final void closeStream(InputStream in) {
        if (in != null) {
            try {
                in.close();//from w  ww  .  jav  a 2s  .  c om
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
    }

    public static final void closeStream(FileInputStream in) {
        if (in != null) {
            try {
                in.close();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
    }

    public static final void closeStream(FileOutputStream in) {
        if (in != null) {
            try {
                in.close();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
    }

    public static final void closeStream(OutputStream out) {
        if (out != null) {
            try {
                out.close();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
    }

    /**
     * 
     * @param raf
     */
    public static final void closeStream(RandomAccessFile raf) {
        if (raf != null) {
            try {
                raf.close();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }

    }

    public static void closeStream(Writer wr) {
        if (wr != null) {
            try {
                wr.close();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }

    }
}

Related

  1. closeStream(Closeable closeable)
  2. closeStream(Closeable stream)
  3. closeStream(Closeable stream)
  4. closeStream(Closeable... closeable)
  5. closeStream(Closeable... streams)
  6. closeStream(final Closeable stream)
  7. closeStream(final InputStream in)
  8. closeStream(final InputStream stream)
  9. closeStream(final java.io.Closeable stream)