List of usage examples for java.io File mkdir
public boolean mkdir()
From source file:net.sf.jvifm.Main.java
public static void initConfigDir() { File file = new File(HomeLocator.getConfigHome()); if (!file.exists()) file.mkdir(); }
From source file:com.manydesigns.elements.util.ElementsFileUtils.java
public static boolean safeMkdir(File detailDirectory) { try {//from www. j a v a 2 s .c o m return detailDirectory.mkdir(); } catch (SecurityException e) { logger.error("mkdir failed, security exception", e); return false; } }
From source file:com.ms.commons.test.treedb.Objects2XmlFileUtil.java
private static File getFile(String testMethodName, BuiltInCacheKey prePareOrResult) { // basePathsrcPath basePath = StringUtils.replace(basePath, "target/classes.eclipse_test", "src/java.test"); File file = new File(basePath); if (!file.exists()) { file.mkdir(); }/*w w w . j a va 2s .c om*/ if (testMethodName.indexOf('_') <= 0) { testMethodName = testMethodName + "_" + prePareOrResult.getValue(); } String defaultExt = DataReaderUtil.getDefaultExt(DataReaderType.TreeXml); String relativePath = basePath + "/" + testMethodName; if (!relativePath.endsWith(defaultExt)) { relativePath = relativePath + defaultExt; } return new File(relativePath); }
From source file:Main.java
private static void makePerTilePerCycleFiles(final File parentDir, final int lane, final List<Integer> tiles, final int[] cycles, final String ext) { if (!parentDir.exists()) { if (!parentDir.mkdir()) { throw new RuntimeException("Couldn't create directory " + parentDir.getAbsolutePath()); }// w ww . j a v a 2 s .c o m } for (final int cycle : cycles) { final File cycleDir = new File(parentDir, "C" + cycle + ".1"); if (!cycleDir.exists()) { if (!cycleDir.mkdir()) { throw new RuntimeException("Couldn't create directory " + cycleDir.getAbsolutePath()); } } for (final Integer tile : tiles) { writeNonEmptyFile(new File(cycleDir, "s_" + lane + "_" + tile + ext)); } } }
From source file:cn.dreampie.common.plugin.lesscss.compiler.NodeJsLessCssCompiler.java
private static File createTempDir(String prefix) { final int tempDirAttempts = 10000; File baseDir = new File(System.getProperty("java.io.tmpdir")); String baseName = prefix + "-" + System.currentTimeMillis() + "-"; for (int counter = 0; counter < tempDirAttempts; counter++) { File tempDir = new File(baseDir, baseName + counter); if (tempDir.mkdir()) { return tempDir; }//w w w . j a va 2s . co m } throw new IllegalStateException("Failed to create directory within " + tempDirAttempts + " attempts (tried " + baseName + "0 to " + baseName + (tempDirAttempts - 1) + ')'); }
From source file:Main.java
/*** * write a line to the log file// w w w . ja v a 2 s. c o m * * @param line */ public static void writeToLog(String line) { DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); Date date = new Date(); File f = new File(Environment.getExternalStorageDirectory() + File.separator + folderName); boolean success = true; if (!f.exists()) { success = f.mkdir(); } if (success) { // Do something on success File fileDir = new File(f, dateFormat.format(date) + ".txt"); try { FileOutputStream os = new FileOutputStream(fileDir, true); os.write(line.getBytes()); os.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }
From source file:Main.java
/** * Get the application folder for bookmarks export. Create it if not present. * @return The application folder for bookmarks export. *//*from w w w.ja v a 2 s . c om*/ public static File getBookmarksExportFolder() { File root = getApplicationFolder(); if (root != null) { File folder = new File(root, BOOKMARKS_EXPORT_FOLDER); if (!folder.exists()) { folder.mkdir(); } return folder; } else { return null; } }
From source file:com.thoughtworks.go.helpers.FileSystemUtils.java
public static File createDirectory(String directoryName) { File directory = new File(getTestRootDir(), directoryName); deleteDirectory(directory);//from w w w .j a v a2 s. c om directory.mkdir(); directory.deleteOnExit(); return directory; }
From source file:com.eatnumber1.util.io.FileUtils.java
public static void mkdir(@NotNull File directory) throws IOException { if (!directory.exists() && !directory.mkdir()) throw new IOException("Unable to create directory."); }
From source file:com.founder.fix.fixflow.explorer.util.FileHandle.java
public static String updload(HttpServletRequest request, HttpServletResponse response, String autoPath, String showFileName) throws Exception { String message = ""; // ?? //from w w w . j av a 2s . c o m File uploadPath = new File(autoPath); if (!uploadPath.exists()) { uploadPath.mkdir(); } for (int i = 0; i < fi.size(); i++) { FileItem fileItem = fi.get(i); if (!fileItem.isFormField()) { //String fieldName = fileItem.getFieldName(); // ????file inputname String fileName = fileItem.getName(); // file input?? //String contentType = fileItem.getContentType(); // //long size = fileItem.getSize(); // String filePath = autoPath + File.separator + showFileName; // org.apache.commons.fileupload.FileItem ??write? // fileItem.write(new File(filePath)); // ???? ? ? OutputStream outputStream = new FileOutputStream(new File(filePath));// ??? InputStream inputStream = fileItem.getInputStream(); int length = 0; byte[] buf = new byte[1024]; while ((length = inputStream.read(buf)) != -1) { // ????? outputStream.write(buf, 0, length); } inputStream.close(); outputStream.close(); message = "(" + fileName + ")?,??:" + filePath; } } return message; }