|
64 | 64 | * @author <a href="mailto:jefft@apache.org">Jeff Turner</a> |
65 | 65 | * @author Matthew Hawthorne |
66 | 66 | * @author <a href="mailto:jeremias@apache.org">Jeremias Maerki</a> |
67 | | - * @version $Id: FileUtils.java,v 1.34 2004/07/15 08:21:14 scolebourne Exp $ |
| 67 | + * @version $Id: FileUtils.java,v 1.35 2004/07/15 09:16:17 jeremias Exp $ |
68 | 68 | */ |
69 | 69 | public class FileUtils { |
70 | 70 |
|
@@ -121,19 +121,23 @@ public static String byteCountToDisplaySize(long size) { |
121 | 121 | * @throws IOException If an I/O problem occurs |
122 | 122 | */ |
123 | 123 | public static void touch(File file) throws IOException { |
124 | | - OutputStream out = new FileOutputStream(file, true); |
125 | | - IOUtils.closeQuietly(out); |
| 124 | + if (!file.exists()) { |
| 125 | + OutputStream out = new FileOutputStream(file); |
| 126 | + IOUtils.closeQuietly(out); |
| 127 | + } |
126 | 128 | file.setLastModified(System.currentTimeMillis()); |
127 | 129 | } |
128 | 130 |
|
129 | 131 |
|
130 | 132 | private static void innerListFiles(Collection files, File directory, IOFileFilter filter) { |
131 | 133 | File[] found = directory.listFiles((FileFilter)filter); |
132 | | - for (int i = 0; i < found.length; i++) { |
133 | | - if (found[i].isDirectory()) { |
134 | | - innerListFiles(files, found[i], filter); |
135 | | - } else { |
136 | | - files.add(found[i]); |
| 134 | + if (found != null) { |
| 135 | + for (int i = 0; i < found.length; i++) { |
| 136 | + if (found[i].isDirectory()) { |
| 137 | + innerListFiles(files, found[i], filter); |
| 138 | + } else { |
| 139 | + files.add(found[i]); |
| 140 | + } |
137 | 141 | } |
138 | 142 | } |
139 | 143 | } |
|
0 commit comments