ecology_maven/aiyh/utils/httpUtil/ExtendedIOUtils.java

40 lines
861 B
Java
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

package aiyh.utils.httpUtil;
import java.io.Closeable;
import java.io.Flushable;
import java.io.IOException;
/**
* IO流拓展工具类补充IOUtils新版本中废弃的closeQuietly
*
* @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
}
}
}
}
}