Example #1
0
 //    private static void copyFile(File f1, String pathOut) throws DAOException {
 //        InputStream in = null;
 //        OutputStream out = null;
 //        try {
 //            String namef2 = f1.getName();
 //            in = new FileInputStream(f1);
 //            out = new FileOutputStream(new File(pathOut + "/" + namef2));
 //            byte[] buf = new byte[1024];
 //            int len;
 //            while ((len = in.read(buf)) > 0) {
 //                out.write(buf, 0, len);
 //            }
 //            in.close();
 //            out.close();
 //            logger.debug("File " + namef2 + " copied.");
 //        } catch (FileNotFoundException ex) {
 //            logger.error(ex.getLocalizedMessage());
 //            throw new DAOException(ex);
 //        } catch (IOException ex) {
 //
 //            throw new DAOException(ex);
 //        } finally {
 //            try {
 //                in.close();
 //                out.close();
 //            } catch (Exception ex) {
 //            }
 //        }
 //    }
 public static void loadTools(Scenario scenario, List<String> tools) throws DAOException {
   File directory = new File(scenario.getOutPath());
   for (final String name : tools) {
     FileFilter filter =
         new FileFilter() {
           public boolean accept(File pathname) {
             if (pathname.isDirectory() && pathname.getName().equals(name)) {
               return true;
             }
             return false;
           }
         };
     File[] subDir = directory.listFiles(filter);
     if (subDir.length != 0) {
       File file = subDir[0];
       MappingTool tool = loadTool(file.getAbsolutePath());
       if (tool != null) {
         scenario.addTool(tool);
       }
     }
   }
 }