ecology_maven/aiyh/utils/httpUtil/ExtendedIOUtils.java

40 lines
861 B
Java
Raw Normal View History

2021-11-14 15:29:16 +08:00
package aiyh.utils.httpUtil;
import java.io.Closeable;
import java.io.Flushable;
import java.io.IOException;
/**
* IOIOUtilscloseQuietly
*
* @author EBU7-dev1-ayh
* @since 2021/08/30 17:56
*/
public class ExtendedIOUtils {
public static void flush(Flushable... resources) throws IOException {
int length = resources.length;
for (int i = 0; i < length; ++i) {
Flushable resource = resources[i];
if (resource != null) {
resource.flush();
}
}
}
public static void closeQuietly(Closeable... resources) {
int length = resources.length;
for (int i = 0; i < length; ++i) {
Closeable resource = resources[i];
if (resource != null) {
try {
resource.close();
} catch (IOException e) {
//ignore exception
}
}
}
}
}