本文實例為大家分享了java關閉流連接IO工具類的具體代碼,供大家參考,具體內容如下
package com.demo.utils;import java.io.IOException;import java.io.InputStream;import java.io.OutputStream;import java.io.Reader;import java.io.Writer;/** * 關閉流連接IO工具類* @author dongyangyang * @Date 2016/12/28 23:12 * @Version 1.0 * */public class IOUtils { public static void close(InputStream in) { if (in != null) { try { in.close(); } catch (IOException e) { } } } public static void close(OutputStream out){ if (out != null) { try { out.close(); } catch (IOException e) { } } } public static void close(Reader r) { if (r != null) { try { r.close(); } catch (IOException e) { } } } public static void close(Writer w){ if (w != null) { try { w.close(); } catch (IOException e) { } } }}以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持武林網。