Mercurial > dive4elements > framework
comparison artifacts-common/src/main/java/de/intevation/artifacts/common/utils/FileTools.java @ 369:c489256a188b
Replaced legacy java.util.Stack with java.util.Deque.
artifacts/trunk@3683 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Mon, 16 Jan 2012 10:03:42 +0000 |
parents | 0723859f776f |
children | b076c9e9fdfd |
comparison
equal
deleted
inserted
replaced
368:8e18697d99fb | 369:c489256a188b |
---|---|
14 import java.io.FileInputStream; | 14 import java.io.FileInputStream; |
15 import java.io.FileOutputStream; | 15 import java.io.FileOutputStream; |
16 import java.io.OutputStream; | 16 import java.io.OutputStream; |
17 import java.nio.channels.FileChannel; | 17 import java.nio.channels.FileChannel; |
18 | 18 |
19 import java.util.Stack; | 19 import java.util.Deque; |
20 import java.util.ArrayDeque; | |
20 import java.util.List; | 21 import java.util.List; |
21 import java.util.Set; | 22 import java.util.Set; |
22 import java.util.HashSet; | 23 import java.util.HashSet; |
23 import java.util.ArrayList; | 24 import java.util.ArrayList; |
24 import java.util.zip.ZipEntry; | 25 import java.util.zip.ZipEntry; |
62 public static File repair(File file) { | 63 public static File repair(File file) { |
63 file = file.getAbsoluteFile(); | 64 file = file.getAbsoluteFile(); |
64 if (file.exists()) { | 65 if (file.exists()) { |
65 return file; | 66 return file; |
66 } | 67 } |
67 Stack<String> parts = new Stack<String>(); | 68 Deque<String> parts = new ArrayDeque<String>(); |
68 File curr = file; | 69 File curr = file; |
69 while (curr != null) { | 70 while (curr != null) { |
70 String name = curr.getName(); | 71 String name = curr.getName(); |
71 if (name.length() > 0) { | 72 if (name.length() > 0) { |
72 parts.push(curr.getName()); | 73 parts.push(curr.getName()); |
230 boolean visit(File file); | 231 boolean visit(File file); |
231 } // Visitor | 232 } // Visitor |
232 | 233 |
233 public static void walkTree(File root, FileVisitor visitor) { | 234 public static void walkTree(File root, FileVisitor visitor) { |
234 | 235 |
235 Stack<File> stack = new Stack<File>(); | 236 Deque<File> stack = new ArrayDeque<File>(); |
236 | 237 |
237 stack.push(root); | 238 stack.push(root); |
238 | 239 |
239 while (!stack.isEmpty()) { | 240 while (!stack.isEmpty()) { |
240 File current = stack.pop(); | 241 File current = stack.pop(); |
315 if (file.isFile()) { | 316 if (file.isFile()) { |
316 copyFileToZip("", file, out); | 317 copyFileToZip("", file, out); |
317 } | 318 } |
318 else if (file.isDirectory()) { | 319 else if (file.isDirectory()) { |
319 | 320 |
320 Stack<PrefixDir> stack = new Stack<PrefixDir>(); | 321 Deque<PrefixDir> stack = new ArrayDeque<PrefixDir>(); |
321 stack.push(new PrefixDir(file.getName() + "/", file)); | 322 stack.push(new PrefixDir(file.getName() + "/", file)); |
322 | 323 |
323 while (!stack.isEmpty()) { | 324 while (!stack.isEmpty()) { |
324 PrefixDir pd = stack.pop(); | 325 PrefixDir pd = stack.pop(); |
325 | 326 |