create a folder for multiple numbers in java code example
Example 1: create a folder for multiple numbers in java
fullPathFile.getParentFile().mkdirs();
Example 2: create a folder for multiple numbers in java
public static void main(String[] args) {
String dirPath = "D:\\temp\\";
File dir = new File(dirPath);
File[] fileList = dir.listFiles();
for(int i=0; i < fileList.length; i++)
{
if(fileList[i].isFile()) {
String fileName = fileList[i].getName();
String[] fileParts = fileName.split("[_\\.]");
System.out.println("One: " + fileParts[0] + ", Two: " + fileParts[1]);
File newDir = new File(dirPath + fileParts[0] + "\\" + fileParts[1]);
if(!newDir.exists()) {
if(newDir.mkdirs()) {
System.out.println("Directory Created");
}
}
if(fileList[i].renameTo(new File(dirPath + fileParts[0] + "\\" + fileParts[1] + "\\" + fileName))) {
System.out.println("File Moved");
}
}
}
}