Java Stream Close closeStreams(InputStream iStream, OutputStream oStream)

Here you can find the source of closeStreams(InputStream iStream, OutputStream oStream)

Description

close Streams

License

Apache License

Declaration

public static void closeStreams(InputStream iStream, OutputStream oStream) 

Method Source Code

//package com.java2s;
/*/*w  w  w . j a v a  2 s  .  c o m*/
 * Copyright 2016 Rajesh Putta
       
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
    
   http://www.apache.org/licenses/LICENSE-2.0
    
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
 */

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

public class Main {
    public static void closeStreams(InputStream iStream, OutputStream oStream) {
        if (iStream != null) {
            try {
                iStream.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

        if (oStream != null) {
            try {
                oStream.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}

Related

  1. closeStream(Object oin)
  2. closeStream(OutputStream os)
  3. closeStreamIgnoreExpection(InputStream stream)
  4. closeStreamQuietly(final Closeable closeable)
  5. closeStreams(FileInputStream fis, FileOutputStream fos)
  6. closeStreams(InputStream src, OutputStream dest)
  7. closeStreams(Process process)
  8. closeUnchecked(InputStream stream)
  9. closeWarnOnError(Closeable stream, Logger log, String message)