01: /******************************************************************************
02: * Copyright (C) Lars Ivar Almli. All rights reserved. *
03: * ---------------------------------------------------------------------------*
04: * This file is part of MActor. *
05: * *
06: * MActor is free software; you can redistribute it and/or modify *
07: * it under the terms of the GNU General Public License as published by *
08: * the Free Software Foundation; either version 2 of the License, or *
09: * (at your option) any later version. *
10: * *
11: * MActor is distributed in the hope that it will be useful, *
12: * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14: * GNU General Public License for more details. *
15: * *
16: * You should have received a copy of the GNU General Public License *
17: * along with MActor; if not, write to the Free Software *
18: * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
19: ******************************************************************************/package org.mactor.tests;
20:
21: import java.io.File;
22:
23: public class Util {
24: public static File getFirstFile(String dir) throws Exception {
25: File d = new File(dir);
26: if (d.exists()) {
27: File[] files = d.listFiles();
28: for (File file : files) {
29: if (!file.isDirectory()
30: && file.getName().endsWith(".xml"))
31: return file;
32: }
33: }
34: return null;
35: }
36:
37: public static void clearDir(String dir) throws Exception {
38: File d = new File(dir);
39: if (d.exists()) {
40: File[] files = d.listFiles();
41: for (File file : files) {
42: if (!file.isDirectory()
43: && file.getName().endsWith(".xml"))
44: if (!file.delete())
45: throw new Exception("Unable to clear dir: "
46: + dir);
47: }
48: }
49: }
50: }
|