Skip to content
Snippets Groups Projects
Commit 8a5628f1 authored by ribeaudc's avatar ribeaudc
Browse files

change:

- Ensure that given file is not a directory.

SVN: 2880
parent 8b17f5fe
No related branches found
No related tags found
No related merge requests found
...@@ -147,10 +147,11 @@ public final class FileUtilities ...@@ -147,10 +147,11 @@ public final class FileUtilities
* *
* @throws CheckedExceptionTunnel for wrapping an {@link IOException}. * @throws CheckedExceptionTunnel for wrapping an {@link IOException}.
*/ */
public static void writeToFile(File file, String str) throws CheckedExceptionTunnel public static void writeToFile(final File file, final String str) throws CheckedExceptionTunnel
{ {
assert file != null : "Unspecified file."; assert file != null : "Unspecified file.";
assert str != null : "Unspecified string."; assert str != null : "Unspecified string.";
assert file.isDirectory() == false : String.format("Given file '%s' already exists and is a directory.", file);
FileWriter fileWriter = null; FileWriter fileWriter = null;
try try
...@@ -868,7 +869,7 @@ public final class FileUtilities ...@@ -868,7 +869,7 @@ public final class FileUtilities
return file.getAbsolutePath(); return file.getAbsolutePath();
} }
} }
/** /**
* Returns <code>true</code>, if the (remote resource) <var>path</var> becomes available within * Returns <code>true</code>, if the (remote resource) <var>path</var> becomes available within
* <var>timeOutMillis</var> milli-seconds. * <var>timeOutMillis</var> milli-seconds.
...@@ -878,28 +879,28 @@ public final class FileUtilities ...@@ -878,28 +879,28 @@ public final class FileUtilities
final Semaphore sem = new Semaphore(1); final Semaphore sem = new Semaphore(1);
sem.acquireUninterruptibly(); sem.acquireUninterruptibly();
final Thread t = new Thread(new Runnable() final Thread t = new Thread(new Runnable()
{
public void run()
{ {
boolean pathExists = false; public void run()
do
{ {
pathExists = path.exists(); boolean pathExists = false;
if (pathExists) do
{
sem.release();
return;
}
try
{ {
Thread.sleep(timeOutMillis / 10L); pathExists = path.exists();
} catch (InterruptedException ex) if (pathExists)
{ {
return; sem.release();
} return;
} while (true); }
} try
}, "Path Availability Checker: " + path.getPath()); {
Thread.sleep(timeOutMillis / 10L);
} catch (InterruptedException ex)
{
return;
}
} while (true);
}
}, "Path Availability Checker: " + path.getPath());
t.start(); t.start();
try try
{ {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment