List of usage examples for org.apache.commons.io FileUtils writeLines
public static void writeLines(File file, Collection lines) throws IOException
toString()
value of each item in a collection to the specified File
line by line. From source file:com.sishuok.es.maintain.icon.web.controller.IconController.java
/** * ? ? ??/*from w ww . j a v a 2s. c om*/ * * @param request * @return */ @RequestMapping(value = "/genCssFile") @ResponseBody public String genIconCssFile(HttpServletRequest request) { this.permissionList.assertHasEditPermission(); String uploadFileTemplate = ".%1$s{background:url(%2$s/%3$s);width:%4$spx;height:%5$spx;display:inline-block;vertical-align: middle;%6$s}"; String cssSpriteTemplate = ".%1$s{background:url(%2$s/%3$s) no-repeat -%4$spx -%5$spx;width:%6$spx;height:%7$spx;display:inline-block;vertical-align: middle;%8$s}"; ServletContext sc = request.getServletContext(); String ctx = sc.getContextPath(); List<String> cssList = Lists.newArrayList(); Searchable searchable = Searchable.newSearchable().addSearchParam("type_in", new IconType[] { IconType.upload_file, IconType.css_sprite }); List<Icon> iconList = baseService.findAllWithNoPageNoSort(searchable); for (Icon icon : iconList) { if (icon.getType() == IconType.upload_file) { cssList.add(String.format(uploadFileTemplate, icon.getIdentity(), ctx, icon.getImgSrc(), icon.getWidth(), icon.getHeight(), icon.getStyle())); continue; } if (icon.getType() == IconType.css_sprite) { cssList.add(String.format(cssSpriteTemplate, icon.getIdentity(), ctx, icon.getSpriteSrc(), icon.getLeft(), icon.getTop(), icon.getWidth(), icon.getHeight(), icon.getStyle())); continue; } } try { ServletContextResource resource = new ServletContextResource(sc, iconClassFile); FileUtils.writeLines(resource.getFile(), cssList); } catch (Exception e) { LogUtils.logError("gen icon error", e); return "?" + e.getMessage(); } return "??"; }
From source file:ch.unibas.fittingwizard.infrastructure.RealVmdDisplayScript.java
private void createModifiedVdwFile(File vdwInputFile, File vdwOutputFile, int fitRank) { List<String> lines; List<String> modLines = new LinkedList<String>(); try {/*from w w w . j av a2 s.co m*/ lines = FileUtils.readLines(vdwInputFile); } catch (IOException e) { throw new RuntimeException("Could not read form vdw file.\n" + vdwInputFile.getAbsolutePath(), e); } for (String line : lines) { String modifiedLine = line.replaceAll("[0-2]$", String.valueOf(fitRank)); modLines.add(modifiedLine); } try { FileUtils.writeLines(vdwOutputFile, modLines); } catch (IOException e) { throw new RuntimeException("Could not write to modified vdw file.\n" + vdwOutputFile.getAbsolutePath(), e); } }
From source file:com.gargoylesoftware.htmlunit.source.BrowserVersionFeaturesSource.java
/** * Reverses the specified {@link BrowserVersionFeatures} to the other browsers (by modifying only * the configuration files)./* w ww. j ava2 s . c o m*/ * For example, if it is currently defined in IE8 and FF3, the BrowserFeatures will be removed from those browsers * configurations and added to the others ones. * * This is useful if you have something like "!browserVersion.hasFeature()" and you need to reverse the condition. * * @param features the feature to reverse * @throws IOException if an error occurs */ public void reverse(final BrowserVersionFeatures features) throws IOException { final File propertiesFolder = new File(root_, "src/main/resources/com/gargoylesoftware/htmlunit/javascript/configuration"); for (final File f : propertiesFolder.listFiles(new FileFilter() { public boolean accept(final File pathname) { return pathname.getName().endsWith(".properties"); } })) { final List<String> list = FileUtils.readLines(f); final String name = features.name(); if (list.contains(name)) { list.remove(name); } else { list.add(name); } Collections.sort(list); FileUtils.writeLines(f, list); } }
From source file:com.luna.maintain.icon.web.controller.IconController.java
/** * ? ? ??/*from ww w . ja v a 2s . com*/ * * @param request * @return */ @RequestMapping(value = "/genCssFile") @ResponseBody public String genIconCssFile(HttpServletRequest request) { this.permissionList.assertHasEditPermission(); String uploadFileTemplate = ".%1$s{background:url(%2$s/%3$s);width:%4$spx;height:%5$spx;display:inline-block;vertical-align: middle;%6$s}"; String cssSpriteTemplate = ".%1$s{background:url(%2$s/%3$s) no-repeat -%4$spx -%5$spx;width:%6$spx;height:%7$spx;display:inline-block;vertical-align: middle;%8$s}"; ServletContext sc = request.getServletContext(); String ctx = sc.getContextPath(); List<String> cssList = Lists.newArrayList(); Searchable searchable = Searchable.newSearchable().addSearchParam("type_in", new IconType[] { IconType.upload_file, IconType.css_sprite }); List<Icon> iconList = baseService.findAllWithNoPageNoSort(searchable); for (Icon icon : iconList) { if (icon.getType() == IconType.upload_file) { cssList.add(String.format(uploadFileTemplate, icon.getIdentity(), ctx, icon.getImgSrc(), icon.getWidth(), icon.getHeight(), icon.getStyle())); continue; } if (icon.getType() == IconType.css_sprite) { cssList.add(String.format(cssSpriteTemplate, icon.getIdentity(), ctx, icon.getSpriteSrc(), icon.getLeft(), icon.getTop(), icon.getWidth(), icon.getHeight(), icon.getStyle())); continue; } } try { ServletContextResource resource = new ServletContextResource(sc, iconClassFile); FileUtils.writeLines(resource.getFile(), cssList); } catch (Exception e) { log.error("gen icon error", e); return "?" + e.getMessage(); } return "??"; }
From source file:de.baumann.hhsmoodle.activities.Activity_todo.java
private void writeItems() { try { FileUtils.writeLines(newFile(), items); } catch (IOException e) { e.printStackTrace(); } }
From source file:ai.h2o.servicebuilder.MakePythonWarServlet.java
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { Long startTime = System.currentTimeMillis(); File tmpDir = null;/* w w w . ja v a 2s. c om*/ try { //create temp directory tmpDir = createTempDirectory("makeWar"); logger.debug("tmpDir " + tmpDir); // create output directories File webInfDir = new File(tmpDir.getPath(), "WEB-INF"); if (!webInfDir.mkdir()) throw new Exception("Can't create output directory (WEB-INF)"); File outDir = new File(webInfDir.getPath(), "classes"); if (!outDir.mkdir()) throw new Exception("Can't create output directory (WEB-INF/classes)"); File libDir = new File(webInfDir.getPath(), "lib"); if (!libDir.mkdir()) throw new Exception("Can't create output directory (WEB-INF/lib)"); // get input files List<FileItem> items = new ServletFileUpload(new DiskFileItemFactory()).parseRequest(request); String pojofile = null; String jarfile = null; String mojofile = null; String pythonfile = null; String predictorClassName = null; String pythonenvfile = null; ArrayList<String> pojos = new ArrayList<String>(); ArrayList<String> rawfiles = new ArrayList<String>(); for (FileItem i : items) { String field = i.getFieldName(); String filename = i.getName(); if (filename != null && filename.length() > 0) { if (field.equals("pojo")) { // pojo file name, use this or a mojo file pojofile = filename; pojos.add(pojofile); predictorClassName = filename.replace(".java", ""); FileUtils.copyInputStreamToFile(i.getInputStream(), new File(tmpDir, filename)); logger.info("added pojo model {}", filename); } if (field.equals("jar")) { jarfile = "WEB-INF" + File.separator + "lib" + File.separator + filename; FileUtils.copyInputStreamToFile(i.getInputStream(), new File(libDir, filename)); } if (field.equals("python")) { pythonfile = "WEB-INF" + File.separator + "python.py"; FileUtils.copyInputStreamToFile(i.getInputStream(), new File(webInfDir, "python.py")); } if (field.equals("pythonextra")) { // optional extra files for python pythonfile = "WEB-INF" + File.separator + "lib" + File.separator + filename; FileUtils.copyInputStreamToFile(i.getInputStream(), new File(libDir, filename)); } if (field.equals("mojo")) { // a raw model zip file, a mojo file (optional) mojofile = filename; rawfiles.add(mojofile); predictorClassName = filename.replace(".zip", ""); FileUtils.copyInputStreamToFile(i.getInputStream(), new File(tmpDir, filename)); logger.info("added mojo model {}", filename); } if (field.equals("envfile")) { // optional conda environment file pythonenvfile = filename; FileUtils.copyInputStreamToFile(i.getInputStream(), new File(tmpDir, filename)); logger.debug("using conda environment file {}", pythonenvfile); } } } logger.debug("jar {} pojo {} mojo {} python {} envfile {}", jarfile, pojofile, mojofile, pythonfile, pythonenvfile); if ((pojofile == null || jarfile == null) && (mojofile == null || jarfile == null)) throw new Exception("need either pojo and genmodel jar, or raw file and genmodel jar "); if (pojofile != null) { // Compile the pojo runCmd(tmpDir, Arrays.asList("javac", "-target", JAVA_TARGET_VERSION, "-source", JAVA_TARGET_VERSION, "-J-Xmx" + MEMORY_FOR_JAVA_PROCESSES, "-cp", jarfile, "-d", outDir.getPath(), pojofile), "Compilation of pojo failed"); logger.info("compiled pojo {}", pojofile); } if (servletPath == null) throw new Exception("servletPath is null"); FileUtils.copyDirectoryToDirectory(new File(servletPath, "extra"), tmpDir); String extraPath = "extra" + File.separator; String webInfPath = extraPath + File.separator + "WEB-INF" + File.separator; String srcPath = extraPath + "src" + File.separator; copyExtraFile(servletPath, extraPath, tmpDir, "pyindex.html", "index.html"); copyExtraFile(servletPath, extraPath, tmpDir, "jquery.js", "jquery.js"); copyExtraFile(servletPath, extraPath, tmpDir, "predict.js", "predict.js"); copyExtraFile(servletPath, extraPath, tmpDir, "custom.css", "custom.css"); copyExtraFile(servletPath, webInfPath, webInfDir, "web-pythonpredict.xml", "web.xml"); FileUtils.copyDirectoryToDirectory(new File(servletPath, webInfPath + "lib"), webInfDir); FileUtils.copyDirectoryToDirectory(new File(servletPath, extraPath + "bootstrap"), tmpDir); FileUtils.copyDirectoryToDirectory(new File(servletPath, extraPath + "fonts"), tmpDir); // change the class name in the predictor template file to the predictor we have String modelCode = null; if (!pojos.isEmpty()) { FileUtils.writeLines(new File(tmpDir, "modelnames.txt"), pojos); modelCode = "null"; } else if (!rawfiles.isEmpty()) { FileUtils.writeLines(new File(tmpDir, "modelnames.txt"), rawfiles); modelCode = "MojoModel.load(fileName)"; } InstantiateJavaTemplateFile(tmpDir, modelCode, predictorClassName, "null", pythonenvfile == null ? "" : pythonenvfile, srcPath + "ServletUtil-TEMPLATE.java", "ServletUtil.java"); copyExtraFile(servletPath, srcPath, tmpDir, "PredictPythonServlet.java", "PredictPythonServlet.java"); copyExtraFile(servletPath, srcPath, tmpDir, "InfoServlet.java", "InfoServlet.java"); copyExtraFile(servletPath, srcPath, tmpDir, "StatsServlet.java", "StatsServlet.java"); copyExtraFile(servletPath, srcPath, tmpDir, "PingServlet.java", "PingServlet.java"); copyExtraFile(servletPath, srcPath, tmpDir, "Transform.java", "Transform.java"); copyExtraFile(servletPath, srcPath, tmpDir, "Logging.java", "Logging.java"); // compile extra runCmd(tmpDir, Arrays.asList("javac", "-target", JAVA_TARGET_VERSION, "-source", JAVA_TARGET_VERSION, "-J-Xmx" + MEMORY_FOR_JAVA_PROCESSES, "-cp", "WEB-INF/lib/*:WEB-INF/classes:extra/WEB-INF/lib/*", "-d", outDir.getPath(), "InfoServlet.java", "StatsServlet.java", "PredictPythonServlet.java", "ServletUtil.java", "PingServlet.java", "Transform.java", "Logging.java"), "Compilation of servlet failed"); // create the war jar file Collection<File> filesc = FileUtils.listFilesAndDirs(webInfDir, TrueFileFilter.INSTANCE, TrueFileFilter.INSTANCE); filesc.add(new File(tmpDir, "index.html")); filesc.add(new File(tmpDir, "jquery.js")); filesc.add(new File(tmpDir, "predict.js")); filesc.add(new File(tmpDir, "custom.css")); filesc.add(new File(tmpDir, "modelnames.txt")); for (String m : pojos) { filesc.add(new File(tmpDir, m)); } for (String m : rawfiles) { filesc.add(new File(tmpDir, m)); } Collection<File> dirc = FileUtils.listFilesAndDirs(new File(tmpDir, "bootstrap"), TrueFileFilter.INSTANCE, TrueFileFilter.INSTANCE); filesc.addAll(dirc); dirc = FileUtils.listFilesAndDirs(new File(tmpDir, "fonts"), TrueFileFilter.INSTANCE, TrueFileFilter.INSTANCE); filesc.addAll(dirc); File[] files = filesc.toArray(new File[] {}); if (files.length == 0) throw new Exception("Can't list compiler output files (out)"); byte[] resjar = createJarArchiveByteArray(files, tmpDir.getPath() + File.separator); if (resjar == null) throw new Exception("Can't create war of compiler output"); logger.info("war created from {} files, size {}", files.length, resjar.length); // send jar back ServletOutputStream sout = response.getOutputStream(); response.setContentType("application/octet-stream"); String outputFilename = predictorClassName.length() > 0 ? predictorClassName : "h2o-predictor"; response.setHeader("Content-disposition", "attachment; filename=" + outputFilename + ".war"); response.setContentLength(resjar.length); sout.write(resjar); sout.close(); response.setStatus(HttpServletResponse.SC_OK); Long elapsedMs = System.currentTimeMillis() - startTime; logger.info("Done python war creation in {}", elapsedMs); } catch (Exception e) { logger.error("doPost failed", e); // send the error message back String message = e.getMessage(); if (message == null) message = "no message"; logger.error(message); response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); response.getWriter().write(message); response.getWriter().write(Arrays.toString(e.getStackTrace())); response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.getMessage()); } finally { // if the temp directory is still there we delete it if (tmpDir != null && tmpDir.exists()) { try { FileUtils.deleteDirectory(tmpDir); } catch (IOException e) { logger.error("Can't delete tmp directory"); } } } }
From source file:es.uvigo.ei.sing.adops.datatypes.Project.java
private void createNamesFile() throws IOException { final List<String> originalLines = FileUtils.readLines(this.originalFastaFile); final List<String> fastaLines = new ArrayList<>(); final List<String> namesLines = new ArrayList<>(); int i = 1;/* w w w. j a v a 2 s . c o m*/ for (String l : originalLines) { if (l.startsWith(">")) { fastaLines.add(">C" + i); namesLines.add(l.substring(1) + " - C" + i); ++i; } else { fastaLines.add(l); } } FileUtils.writeLines(this.namesFile, namesLines); FileUtils.writeLines(this.renamedFastaFile, fastaLines); }
From source file:ai.h2o.servicebuilder.MakeWarServlet.java
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { Long startTime = System.currentTimeMillis(); File tmpDir = null;//from w w w . j av a 2 s .c o m try { //create temp directory tmpDir = createTempDirectory("makeWar"); logger.info("tmpDir {}", tmpDir); // create output directories File webInfDir = new File(tmpDir.getPath(), "WEB-INF"); if (!webInfDir.mkdir()) throw new Exception("Can't create output directory (WEB-INF)"); File outDir = new File(webInfDir.getPath(), "classes"); if (!outDir.mkdir()) throw new Exception("Can't create output directory (WEB-INF/classes)"); File libDir = new File(webInfDir.getPath(), "lib"); if (!libDir.mkdir()) throw new Exception("Can't create output directory (WEB-INF/lib)"); // get input files List<FileItem> items = new ServletFileUpload(new DiskFileItemFactory()).parseRequest(request); String pojofile = null; String jarfile = null; String prejarfile = null; String deepwaterjarfile = null; String rawfile = null; String predictorClassName = null; String transformerClassName = null; ArrayList<String> pojos = new ArrayList<String>(); ArrayList<String> rawfiles = new ArrayList<String>(); for (FileItem i : items) { String field = i.getFieldName(); String filename = i.getName(); if (filename != null && filename.length() > 0) { // file fields if (field.equals("pojo")) { pojofile = filename; pojos.add(pojofile); predictorClassName = filename.replace(".java", ""); FileUtils.copyInputStreamToFile(i.getInputStream(), new File(tmpDir, filename)); logger.info("added pojo model {}", filename); } if (field.equals("jar")) { jarfile = "WEB-INF" + File.separator + "lib" + File.separator + filename; FileUtils.copyInputStreamToFile(i.getInputStream(), new File(libDir, filename)); } if (field.equals("deepwater")) { deepwaterjarfile = "WEB-INF" + File.separator + "lib" + File.separator + filename; FileUtils.copyInputStreamToFile(i.getInputStream(), new File(libDir, filename)); } if (field.equals("prejar")) { prejarfile = "WEB-INF" + File.separator + "lib" + File.separator + filename; FileUtils.copyInputStreamToFile(i.getInputStream(), new File(libDir, filename)); } if (field.equals("mojo")) { // a raw model zip file, a mojo file rawfile = filename; rawfiles.add(rawfile); predictorClassName = filename.replace(".zip", ""); FileUtils.copyInputStreamToFile(i.getInputStream(), new File(tmpDir, filename)); logger.info("added mojo model {}", filename); } } else { // form text field if (field.equals("preclass")) { transformerClassName = i.getString(); } } } logger.debug("genmodeljar {} deepwaterjar {} pojo {} raw {}", jarfile, deepwaterjarfile, pojofile, rawfile); if ((pojofile == null || jarfile == null) && (rawfile == null || jarfile == null)) throw new Exception("need either pojo and genmodel jar, or raw file and genmodel jar "); logger.info("prejar {} preclass {}", prejarfile, transformerClassName); if (prejarfile != null && transformerClassName == null || prejarfile == null && transformerClassName != null) throw new Exception("need both prejar and preclass"); if (pojofile != null) { // Compile the pojo String jarfiles = jarfile; if (deepwaterjarfile != null) jarfiles += ":" + deepwaterjarfile; runCmd(tmpDir, Arrays.asList("javac", "-target", JAVA_TARGET_VERSION, "-source", JAVA_TARGET_VERSION, "-J-Xmx" + MEMORY_FOR_JAVA_PROCESSES, "-cp", jarfiles, "-d", outDir.getPath(), pojofile), "Compilation of pojo failed"); logger.info("compiled pojo {}", pojofile); } if (servletPath == null) throw new Exception("servletPath is null"); FileUtils.copyDirectoryToDirectory(new File(servletPath, "extra"), tmpDir); String extraPath = "extra" + File.separator; String webInfPath = extraPath + File.separator + "WEB-INF" + File.separator; String srcPath = extraPath + "src" + File.separator; if (transformerClassName == null) copyExtraFile(servletPath, extraPath, tmpDir, "index.html", "index.html"); else copyExtraFile(servletPath, extraPath, tmpDir, "jarindex.html", "index.html"); copyExtraFile(servletPath, extraPath, tmpDir, "jquery.js", "jquery.js"); copyExtraFile(servletPath, extraPath, tmpDir, "predict.js", "predict.js"); copyExtraFile(servletPath, extraPath, tmpDir, "custom.css", "custom.css"); copyExtraFile(servletPath, webInfPath, webInfDir, "web-predict.xml", "web.xml"); FileUtils.copyDirectoryToDirectory(new File(servletPath, webInfPath + "lib"), webInfDir); FileUtils.copyDirectoryToDirectory(new File(servletPath, extraPath + "bootstrap"), tmpDir); FileUtils.copyDirectoryToDirectory(new File(servletPath, extraPath + "fonts"), tmpDir); // change the class name in the predictor template file to the predictor we have String replaceTransform; if (transformerClassName == null) replaceTransform = "null"; else replaceTransform = "new " + transformerClassName + "()"; String modelCode = null; if (!pojos.isEmpty()) { FileUtils.writeLines(new File(tmpDir, "modelnames.txt"), pojos); modelCode = "null"; } else if (!rawfiles.isEmpty()) { FileUtils.writeLines(new File(tmpDir, "modelnames.txt"), rawfiles); modelCode = "MojoModel.load(fileName)"; } InstantiateJavaTemplateFile(tmpDir, modelCode, predictorClassName, replaceTransform, null, srcPath + "ServletUtil-TEMPLATE.java", "ServletUtil.java"); copyExtraFile(servletPath, srcPath, tmpDir, "PredictServlet.java", "PredictServlet.java"); copyExtraFile(servletPath, srcPath, tmpDir, "PredictBinaryServlet.java", "PredictBinaryServlet.java"); copyExtraFile(servletPath, srcPath, tmpDir, "InfoServlet.java", "InfoServlet.java"); copyExtraFile(servletPath, srcPath, tmpDir, "StatsServlet.java", "StatsServlet.java"); copyExtraFile(servletPath, srcPath, tmpDir, "PingServlet.java", "PingServlet.java"); copyExtraFile(servletPath, srcPath, tmpDir, "Transform.java", "Transform.java"); copyExtraFile(servletPath, srcPath, tmpDir, "Logging.java", "Logging.java"); // compile extra List<String> cmd = Arrays.asList("javac", "-target", JAVA_TARGET_VERSION, "-source", JAVA_TARGET_VERSION, "-J-Xmx" + MEMORY_FOR_JAVA_PROCESSES, "-cp", "WEB-INF/lib/*:WEB-INF/classes:extra/WEB-INF/lib/*", "-d", outDir.getPath(), "PredictServlet.java", "PredictBinaryServlet.java", "InfoServlet.java", "StatsServlet.java", "ServletUtil.java", "PingServlet.java", "Transform.java", "Logging.java"); runCmd(tmpDir, cmd, "Compilation of extra failed"); // create the war jar file Collection<File> filesc = FileUtils.listFilesAndDirs(webInfDir, TrueFileFilter.INSTANCE, TrueFileFilter.INSTANCE); filesc.add(new File(tmpDir, "index.html")); filesc.add(new File(tmpDir, "jquery.js")); filesc.add(new File(tmpDir, "predict.js")); filesc.add(new File(tmpDir, "custom.css")); filesc.add(new File(tmpDir, "modelnames.txt")); for (String m : pojos) { filesc.add(new File(tmpDir, m)); } for (String m : rawfiles) { filesc.add(new File(tmpDir, m)); } Collection<File> dirc = FileUtils.listFilesAndDirs(new File(tmpDir, "bootstrap"), TrueFileFilter.INSTANCE, TrueFileFilter.INSTANCE); filesc.addAll(dirc); dirc = FileUtils.listFilesAndDirs(new File(tmpDir, "fonts"), TrueFileFilter.INSTANCE, TrueFileFilter.INSTANCE); filesc.addAll(dirc); File[] files = filesc.toArray(new File[] {}); if (files.length == 0) throw new Exception("Can't list compiler output files (out)"); byte[] resjar = createJarArchiveByteArray(files, tmpDir.getPath() + File.separator); if (resjar == null) throw new Exception("Can't create war of compiler output"); logger.info("war created from {} files, size {}", files.length, resjar.length); // send jar back ServletOutputStream sout = response.getOutputStream(); response.setContentType("application/octet-stream"); String outputFilename = predictorClassName.length() > 0 ? predictorClassName : "h2o-predictor"; response.setHeader("Content-disposition", "attachment; filename=" + outputFilename + ".war"); response.setContentLength(resjar.length); sout.write(resjar); sout.close(); response.setStatus(HttpServletResponse.SC_OK); Long elapsedMs = System.currentTimeMillis() - startTime; logger.info("Done war creation in {} ms", elapsedMs); } catch (Exception e) { logger.error("doPost failed ", e); // send the error message back String message = e.getMessage(); if (message == null) message = "no message"; logger.error(message); response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); response.getWriter().write(message); response.getWriter().write(Arrays.toString(e.getStackTrace())); response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.getMessage()); } finally { // if the temp directory is still there we delete it if (tmpDir != null && tmpDir.exists()) { try { FileUtils.deleteDirectory(tmpDir); } catch (IOException e) { logger.error("Can't delete tmp directory"); } } } }
From source file:es.uvigo.ei.sing.adops.datatypes.BatchProject.java
private void createFastasFile() throws IOException { final List<String> fastasNames = new ArrayList<>(this.fastaFiles.length); for (File fastaFile : this.fastaFiles) { fastasNames.add(fastaFile.getName()); }// ww w. j av a 2s .c om FileUtils.writeLines(new File(this.folder, "fasta.names"), fastasNames); }
From source file:com.izforge.izpack.compiler.packager.impl.Packager.java
/** * Write manifest in the install jar./*w w w . j a v a 2 s . c om*/ */ @Override public void writeManifest() throws IOException { IXMLElement data = resourceFinder.getXMLTree(); IXMLElement guiPrefsElement = data.getFirstChildNamed("guiprefs"); // Add splash screen configuration List<String> lines = IOUtils.readLines(getClass().getResourceAsStream("MANIFEST.MF")); IXMLElement splashNode = guiPrefsElement.getFirstChildNamed("splash"); if (splashNode != null) { // Add splash image to installer jar File splashImage = FileUtils .toFile(resourceFinder.findProjectResource(splashNode.getContent(), "Resource", splashNode)); String destination = String.format("META-INF/%s", splashImage.getName()); mergeManager.addResourceToMerge(splashImage.getAbsolutePath(), destination); lines.add(String.format("SplashScreen-Image: %s", destination)); } lines.add(""); File tempManifest = com.izforge.izpack.util.file.FileUtils.createTempFile("MANIFEST", ".MF"); FileUtils.writeLines(tempManifest, lines); mergeManager.addResourceToMerge(tempManifest.getAbsolutePath(), "META-INF/MANIFEST.MF"); }