[Schmitzm-commits] r763 - branches/2.0-GP14/src/schmitzm/io
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Thu Mar 11 09:49:10 CET 2010
Author: alfonx
Date: 2010-03-11 09:49:10 +0100 (Thu, 11 Mar 2010)
New Revision: 763
Modified:
branches/2.0-GP14/src/schmitzm/io/IOUtil.java
Log:
Added to IOUtil: public static boolean canWriteOrCreate(File file)
/**
* Similar to {@link File#canWrite()}, but returns <code>true</code> if the
* file does not exist but can be created.
*
* @param file
* {@link File} to test. May exist or not exist.
*/
Modified: branches/2.0-GP14/src/schmitzm/io/IOUtil.java
===================================================================
--- branches/2.0-GP14/src/schmitzm/io/IOUtil.java 2010-03-11 08:48:00 UTC (rev 762)
+++ branches/2.0-GP14/src/schmitzm/io/IOUtil.java 2010-03-11 08:49:10 UTC (rev 763)
@@ -54,7 +54,8 @@
private static Logger LOGGER = Logger.getLogger(IOUtil.class.getName());
/**
- * {@link FileFilter}, der alle Dateien akzeptiert, aber keine Verzeichnisse.
+ * {@link FileFilter}, der alle Dateien akzeptiert, aber keine
+ * Verzeichnisse.
*/
public static final FileFilter ALL_FILES_FILTER = createSimpleFileFilter(
"*", FilterMode.FILES_ONLY);
@@ -743,4 +744,23 @@
return null;
}
+ /**
+ * Similar to {@link File#canWrite()}, but returns <code>true</code> if the
+ * file does not exist but can be created.
+ *
+ * @param file
+ * {@link File} to test. May exist or not exist.
+ */
+ public static boolean canWriteOrCreate(File file) {
+ if (file.exists())
+ return file.canWrite();
+ try {
+ file.createNewFile();
+ file.delete();
+ return true;
+ } catch (Exception e) {
+ return false;
+ }
+ }
+
}
More information about the Schmitzm-commits
mailing list