@@ -1445,13 +1445,7 @@ public class FileUtils {
* @param device output writer, can be null.
* @param device output writer, can be null.
*/
*/
public static void close(Writer device) {
public static void close(Writer device) {
if (null != device) {
try {
device.close();
} catch (IOException e) {
//ignore
}
}
close((AutoCloseable) device);
}
}
/**
/**
@@ -1461,13 +1455,7 @@ public class FileUtils {
* @param device Reader, can be null.
* @param device Reader, can be null.
*/
*/
public static void close(Reader device) {
public static void close(Reader device) {
if (null != device) {
try {
device.close();
} catch (IOException e) {
//ignore
}
}
close((AutoCloseable) device);
}
}
/**
/**
@@ -1477,13 +1465,7 @@ public class FileUtils {
* @param device stream, can be null.
* @param device stream, can be null.
*/
*/
public static void close(OutputStream device) {
public static void close(OutputStream device) {
if (null != device) {
try {
device.close();
} catch (IOException e) {
//ignore
}
}
close((AutoCloseable) device);
}
}
/**
/**
@@ -1493,13 +1475,7 @@ public class FileUtils {
* @param device stream, can be null.
* @param device stream, can be null.
*/
*/
public static void close(InputStream device) {
public static void close(InputStream device) {
if (null != device) {
try {
device.close();
} catch (IOException e) {
//ignore
}
}
close((AutoCloseable) device);
}
}
/**
/**
@@ -1510,13 +1486,7 @@ public class FileUtils {
* @since Ant 1.8.0
* @since Ant 1.8.0
*/
*/
public static void close(Channel device) {
public static void close(Channel device) {
if (null != device) {
try {
device.close();
} catch (IOException e) {
//ignore
}
}
close((AutoCloseable) device);
}
}
/**
/**
@@ -1543,6 +1513,24 @@ public class FileUtils {
}
}
}
}
/**
* Close an {@link AutoCloseable} without throwing any exception
* if something went wrong. Do not attempt to close it if the
* argument is null.
*
* @param ac AutoCloseable, can be null.
* @since Ant 1.10.0
*/
public static void close(AutoCloseable ac) {
if (null != ac) {
try {
ac.close();
} catch (Exception e) {
//ignore
}
}
}
/**
/**
* Delete the file with {@link File#delete()} if the argument is not null.
* Delete the file with {@link File#delete()} if the argument is not null.
* Do nothing on a null argument.
* Do nothing on a null argument.