create-directory

How to create empty folder in java? [duplicate]

我的未来我决定 提交于 2019-11-27 09:30:42
问题 This question already has answers here : Closed 8 years ago . Possible Duplicate: How to create a folder? I tried to use the File class to create an empty file in a directory like "C:/Temp/Emptyfile". However, when I do that, it shows me an error : "already made folder Temp". Otherwise, it won't create one for me. So, how do I literally create folders with java API? 回答1: Looks file you use the .mkdirs() method on a File object: http://www.roseindia.net/java/beginners/java-create-directory

How to create a folder in Java?

孤街浪徒 提交于 2019-11-26 16:31:55
How can I create an empty folder in Java? Luc M File f = new File("C:\\TEST"); try{ if(f.mkdir()) { System.out.println("Directory Created"); } else { System.out.println("Directory is not created"); } } catch(Exception e){ e.printStackTrace(); } Call File.mkdir , like this: new File(path).mkdir(); micha With Java 7 and newer you can use the static Files.createDirectory() method of the java.nio.file.Files class along with Paths.get . Files.createDirectory(Paths.get("/path/to/folder")); The method Files.createDirectories() also creates parent directories if these do not exist. Use mkdir() : new

How to create a folder in Java?

匆匆过客 提交于 2019-11-26 04:49:20
问题 How can I create an empty folder in Java? 回答1: File f = new File("C:\\TEST"); try{ if(f.mkdir()) { System.out.println("Directory Created"); } else { System.out.println("Directory is not created"); } } catch(Exception e){ e.printStackTrace(); } 回答2: Call File.mkdir, like this: new File(path).mkdir(); 回答3: With Java 7 and newer you can use the static Files.createDirectory() method of the java.nio.file.Files class along with Paths.get. Files.createDirectory(Paths.get("/path/to/folder")); The