| 1 |
/* |
| 2 |
* Copyright 1999-2010 University of Chicago |
| 3 |
* |
| 4 |
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in |
| 5 |
* compliance with the License. You may obtain a copy of the License at |
| 6 |
* |
| 7 |
* http://www.apache.org/licenses/LICENSE-2.0 |
| 8 |
* |
| 9 |
* Unless required by applicable law or agreed to in writing, software distributed under the License is |
| 10 |
* distributed on an "AS IS" BASIS,WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either |
| 11 |
* express or implied. |
| 12 |
* |
| 13 |
* See the License for the specific language governing permissions and limitations under the License. |
| 14 |
*/ |
| 15 |
package org.globus.gsi.util; |
| 16 |
|
| 17 |
import java.io.File; |
| 18 |
import java.io.IOException; |
| 19 |
|
| 20 |
import org.apache.commons.io.FileUtils; |
| 21 |
|
| 22 |
/** |
| 23 |
* FILL ME |
| 24 |
* |
| 25 |
* @author [email protected] |
| 26 |
*/ |
| 27 |
public final class FileUtil { |
| 28 |
|
| 29 |
private FileUtil() { |
| 30 |
//This should not be instantiated. |
| 31 |
} |
| 32 |
|
| 33 |
public static File createFile(String filename) throws IOException { |
| 34 |
|
| 35 |
File f = new File(filename); |
| 36 |
if (!f.createNewFile()) { |
| 37 |
FileUtils.forceDelete(f); |
| 38 |
if (!f.createNewFile()) { |
| 39 |
throw new SecurityException( |
| 40 |
"Failed to atomically create new file"); |
| 41 |
} |
| 42 |
} |
| 43 |
return f; |
| 44 |
} |
| 45 |
|
| 46 |
} |