aboutsummaryrefslogtreecommitdiffstats
path: root/build
diff options
context:
space:
mode:
authorwisberg <wisberg>2003-05-25 19:24:06 +0000
committerwisberg <wisberg>2003-05-25 19:24:06 +0000
commit9c8be5897d3d19564cf7401b42414e49dcc816ae (patch)
tree9c12e3a61ac29b4c8dab66288f69e69c2c7138f4 /build
parent995364f04e270121b0b1c229e6047c7b2823f3b3 (diff)
downloadaspectj-9c8be5897d3d19564cf7401b42414e49dcc816ae.tar.gz
aspectj-9c8be5897d3d19564cf7401b42414e49dcc816ae.zip
delete, close, and isEmpty
Diffstat (limited to 'build')
-rw-r--r--build/src/org/aspectj/internal/tools/build/Util.java34
1 files changed, 34 insertions, 0 deletions
diff --git a/build/src/org/aspectj/internal/tools/build/Util.java b/build/src/org/aspectj/internal/tools/build/Util.java
index 27ca9e1b4..a8d1d2681 100644
--- a/build/src/org/aspectj/internal/tools/build/Util.java
+++ b/build/src/org/aspectj/internal/tools/build/Util.java
@@ -14,6 +14,7 @@
package org.aspectj.internal.tools.build;
+import java.io.*;
import java.io.File;
import java.io.FileFilter;
import java.io.IOException;
@@ -131,6 +132,15 @@ public class Util {
}
/**
+ * Delete file or directory.
+ * @param dir the File file or directory to delete.
+ * @return true if all contents of dir were deleted
+ */
+ public static boolean delete(File dir) {
+ return deleteContents(dir) && dir.delete();
+ }
+
+ /**
* Delete contents of directory.
* The directory itself is not deleted.
* @param dir the File directory whose contents should be deleted.
@@ -169,6 +179,30 @@ public class Util {
}
return tempFile;
}
+ /**
+ * Close stream with the usual checks.
+ * @param stream the InputStream to close - ignored if null
+ * @return null if closed without IOException, message otherwise
+ */
+ public static String close(Writer stream) {
+ String result = null;
+ if (null != stream) {
+ try {
+ stream.close();
+ } catch(IOException e) {
+ result = e.getMessage();
+ }
+ }
+ return result;
+ }
+
+ /**
+ * @param list the Object[] to test
+ * @return true if list is null or empty
+ */
+ public static boolean isEmpty(Object[] list) {
+ return ((null == list) || (0 == list.length));
+ }
}