List of usage examples for java.io File mkdir
public boolean mkdir()
From source file:eu.betaas.taas.taasvmmanager.configuration.TaaSVMMAnagerConfiguration.java
private static void loadPaths() { baseImagesPath = vmImagesPath + "/base"; baseAppImagePath = baseImagesPath + "/app.img"; baseGatewayImagePath = baseImagesPath + "/gateway.img"; baseBigDataImagePath = baseImagesPath + "/bigdata.img"; baseStorageImagePath = baseImagesPath + "/storage.img"; instantiatedImagesPath = vmImagesPath + "/instantiated"; logger.info("Cheking configuration directory structure."); File f = new File(vmImagesPath); if (!f.isDirectory()) { logger.warn("BETaaS VMManager images directory does not exist. Creating..."); if (f.mkdir()) { logger.info("BETaaS VMManager image directory created successfully."); }//from w w w. j a v a 2 s . c om } else { logger.info("BETaaS VMManager base image directory exists."); } f = new File(baseImagesPath); if (!f.isDirectory()) { logger.warn("BETaaS VMManager base images directory does not exist. Creating..."); if (f.mkdir()) { logger.info("BETaaS VMManager base image directory created successfully."); } } else { logger.info("BETaaS VMManager base image directory exists."); } f = new File(instantiatedImagesPath); if (!f.isDirectory()) { logger.warn("BETaaS VMManager instantiated images directory does not exist. Creating..."); if (f.mkdir()) { logger.info("BETaaS VMManager instantiated image directory created successfully."); } } else { logger.info("BETaaS VMManager base image directory exists."); } }
From source file:mx.itesm.mexadl.metrics.util.Util.java
/** * Generate an HTML report for the specified mexadl log. * //from w w w .j a va2 s . c o m * @param logName * @param basedir * @param componentTypes * @throws Exception */ public static void generateHtmlReport(final String logName, final String basedir, final Map<String, String> componentTypes) throws Exception { File logFile; File reportDir; String xsltContent; if (Util.MEXADL_HOME != null) { reportDir = new File(basedir, logName); if (!reportDir.exists()) { reportDir.mkdir(); } logFile = new File("mexadl-" + logName + ".log"); xsltContent = loadFileContent("mx/itesm/mexadl/metrics/" + logName + ".xslt"); xsltContent = xsltContent.replaceAll("MEXADL_HOME", Util.MEXADL_HOME); Util.transformXMLReport2Html(logFile, new ByteArrayInputStream(xsltContent.getBytes("UTF-8")), new File(reportDir, Util.DATE_FORMATTER.format(new Date()).replace(' ', '_') + ".html"), componentTypes); logFile.delete(); } }
From source file:azkaban.jobtype.connectors.teradata.TeraDataWalletInitializer.java
private static File createUnjarDir(final File unjarDir) throws IOException { logger.info("trying to create tdch unjar directory. " + unjarDir.getAbsolutePath()); if (unjarDir.exists()) { logger.info("Delete existing tdch unjar directory. " + unjarDir.getAbsolutePath()); FileUtils.deleteFileOrDirectory(unjarDir); }/*from w ww . ja v a 2s . co m*/ unjarDir.mkdir(); Runtime.getRuntime().addShutdownHook(new Thread() { @Override public void run() { if (unjarDir.exists()) { logger.info("JVM is shutting down. Deleting a folder where TDCH jar is extracted. " + unjarDir.getAbsolutePath()); FileUtils.tryDeleteFileOrDirectory(unjarDir); } } }); logger.info("Created tdch unjar directory. " + unjarDir.getAbsolutePath()); return unjarDir; }
From source file:net.sourceforge.doddle_owl.utils.Utils.java
public static File getJPWNFile(String resName) { File dir = new File(JPWN_TEMP_DIR); if (!dir.exists()) { dir.mkdir(); }/*from w w w . ja va2 s .c o m*/ File file = new File(JPWN_TEMP_DIR + resName); if (file.exists()) { // System.out.println("exist: " + file.getAbsolutePath()); return file; } URL url = DODDLE_OWL.class.getClassLoader().getResource(RESOURCE_DIR + DODDLEConstants.JPWN_HOME + resName); try { FileUtils.copyURLToFile(url, file); } catch (IOException e) { e.printStackTrace(); } // System.out.println("created: " + file.getAbsolutePath()); return file; }
From source file:FileUtils.java
/** * Utility method for copying directory//w w w.ja va 2s.c om * @param srcDir - source directory * @param dstDir - destination directory */ public static void copyDirectory(File srcDir, File dstDir) throws IOException { if (".svn".equals(srcDir.getName())) { return; } if (srcDir.isDirectory()) { if (!dstDir.exists()) { dstDir.mkdir(); } for (String aChildren : srcDir.list()) { copyDirectory(new File(srcDir, aChildren), new File(dstDir, aChildren)); } } else { copyFile(srcDir, dstDir); } }
From source file:it.iit.genomics.cru.bridges.liftover.ws.LiftOverRun.java
public static Mapping runLiftOver(String genome, String fromAssembly, String toAssembly, String chromosome, int start, int end) { String liftOverCommand = RESOURCE_BUNDLE.getString("liftOverCommand"); String liftOverPath = RESOURCE_BUNDLE.getString("liftOverPath"); String mapChainDir = RESOURCE_BUNDLE.getString("mapChainDir"); String tmpDir = RESOURCE_BUNDLE.getString("tmpDir"); Mapping mapping = null;//from www . j av a 2s .c o m Runtime r = Runtime.getRuntime(); String rootFilename = String.format("%s", RandomStringUtils.randomAlphanumeric(8)); String inputFilename = rootFilename + "-" + fromAssembly + ".bed"; String outputFilename = rootFilename + "-" + toAssembly + ".bed"; String unmappedFilename = rootFilename + "-" + "unmapped.bed"; String mapChain = fromAssembly.toLowerCase() + "To" + toAssembly.toUpperCase().charAt(0) + toAssembly.toLowerCase().substring(1) + ".over.chain.gz"; try { File tmpDirFile = new File(tmpDir); // if the directory does not exist, create it if (false == tmpDirFile.exists()) { System.out.println("creating directory: " + tmpDir); boolean result = tmpDirFile.mkdir(); if (result) { System.out.println("DIR created"); } } // Write input bed file File inputFile = new File(tmpDir + inputFilename); // if file doesnt exists, then create it if (!inputFile.exists()) { inputFile.createNewFile(); } FileWriter fw = new FileWriter(inputFile.getAbsoluteFile()); BufferedWriter bw = new BufferedWriter(fw); bw.write(chromosome + "\t" + start + "\t" + end + "\n"); bw.close(); String commandArgs = String.format("%s %s %s %s %s", liftOverPath + "/" + liftOverCommand, tmpDir + inputFilename, mapChainDir + mapChain, tmpDir + outputFilename, tmpDir + unmappedFilename); System.out.println(commandArgs); Process p = r.exec(commandArgs); p.waitFor(); BufferedReader b = new BufferedReader(new InputStreamReader(p.getInputStream())); String line = ""; while ((line = b.readLine()) != null) { System.out.println(line); } b.close(); b = new BufferedReader(new FileReader(tmpDir + outputFilename)); while ((line = b.readLine()) != null) { String[] cells = line.split("\t"); String newChromosome = cells[0]; int newStart = Integer.parseInt(cells[1]); int newEnd = Integer.parseInt(cells[2]); mapping = new Mapping(genome, toAssembly, newChromosome, newStart, newEnd); } b.close(); // delete File delete = new File(tmpDir + inputFilename); delete.delete(); delete = new File(tmpDir + outputFilename); delete.delete(); delete = new File(tmpDir + unmappedFilename); delete.delete(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (InterruptedException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } return mapping; }
From source file:com.github.sakserv.minicluster.impl.KnoxLocalCluster.java
private static boolean copyFilesRecusively(final File toCopy, final File destDir) { assert destDir.isDirectory(); if (!toCopy.isDirectory()) { return copyFile(toCopy, new File(destDir, toCopy.getName())); } else {//from ww w.j ava2s.c o m final File newDestDir = new File(destDir, toCopy.getName()); if (!newDestDir.exists() && !newDestDir.mkdir()) { return false; } for (final File child : toCopy.listFiles()) { if (!copyFilesRecusively(child, newDestDir)) { return false; } } } return true; }
From source file:com.plugin.excel.xsd.node.store.impl.FileHelper.java
public static File getFilePointer(InputStream source, String destName) { File destination; try {/*from w w w . j a va 2 s . c o m*/ destination = File.createTempFile(destName, "temp"); if (!(destination.delete())) { throw new IOException("Could not delete temp file: " + destination.getAbsolutePath()); } if (!(destination.mkdir())) { throw new IOException("Could not create temp directory: " + destination.getAbsolutePath()); } FileUtils.copyInputStreamToFile(source, destination); destination.deleteOnExit(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } return null; }
From source file:ai.h2o.servicebuilder.Util.java
static File createTempDirectory(String prefix) throws IOException { File temp = File.createTempFile(prefix, Long.toString(System.nanoTime())); if (!(temp.delete())) { throw new IOException("Could not delete temp file: " + temp.getAbsolutePath()); }//from w ww. j a va 2 s.co m if (!(temp.mkdir())) { throw new IOException("Could not create temp directory: " + temp.getAbsolutePath()); } return temp; }
From source file:ca.frozen.curlingtv.classes.Utils.java
public static String saveImage(ContentResolver contentResolver, Bitmap source, String title, String description) {/*from w w w. j ava 2 s . c om*/ File snapshot = null; Uri url = null; try { // get/create the snapshots folder File pictures = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES); File rpi = new File(pictures, App.getStr(R.string.app_name)); if (!rpi.exists()) { rpi.mkdir(); } // save the file within the snapshots folder snapshot = new File(rpi, title); OutputStream stream = new FileOutputStream(snapshot); source.compress(Bitmap.CompressFormat.JPEG, 90, stream); stream.flush(); stream.close(); // create the content values ContentValues values = new ContentValues(); values.put(MediaStore.Images.Media.TITLE, title); values.put(MediaStore.Images.Media.DISPLAY_NAME, title); if (description != null) { values.put(MediaStore.Images.Media.DESCRIPTION, description); } values.put(MediaStore.Images.Media.MIME_TYPE, "image/jpeg"); values.put(MediaStore.Images.Media.DATE_ADDED, System.currentTimeMillis()); values.put(MediaStore.Images.Media.DATE_TAKEN, System.currentTimeMillis()); values.put(MediaStore.Images.ImageColumns.BUCKET_ID, snapshot.toString().toLowerCase(Locale.US).hashCode()); values.put(MediaStore.Images.ImageColumns.BUCKET_DISPLAY_NAME, snapshot.getName().toLowerCase(Locale.US)); values.put("_data", snapshot.getAbsolutePath()); // insert the image into the database url = contentResolver.insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values); } catch (Exception ex) { return null; } // return the URL return (url != null) ? url.toString() : null; }