Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

create a folder for multiple numbers in java

public static void main(String[] args) {
    String dirPath = "D:	emp";
    File dir = new File(dirPath);

    // Get Directory Listing
    File[] fileList = dir.listFiles();

    // Process each file
    for(int i=0; i < fileList.length; i++)
    {
        if(fileList[i].isFile()) {
            String fileName = fileList[i].getName();
            // Split at the file extension and the classgroup
            String[] fileParts = fileName.split("[_.]");
            System.out.println("One: " + fileParts[0] + ", Two: " + fileParts[1]);

            // Check directory exists
            File newDir = new File(dirPath + fileParts[0] + "" + fileParts[1]);
            if(!newDir.exists()) {
                // Create directory
                if(newDir.mkdirs()) {
                    System.out.println("Directory Created");
                }
            } 

            // Move file into directory
            if(fileList[i].renameTo(new File(dirPath + fileParts[0] + "" + fileParts[1] + "" + fileName))) {
                System.out.println("File Moved");
            }

        }
    }
}
Comment

create a folder for multiple numbers in java

fullPathFile.getParentFile().mkdirs();
Comment

PREVIOUS NEXT
Code Example
Java :: Simple Write a simple Java program that prints a staircase or a figure as show 
Java :: java forcing user to input int 
Java :: grepper mcm java 
Java :: matlab leslie eigenvalue java 
Java :: getUssd() kotlin 
Java :: how to create simple java bean class for login page in eclipse 
Sql :: sql server reseed single table 
Sql :: mysql reset auto increment value 
Sql :: oracle change nls_date_format permanently 
Sql :: postgres get columns names 
Sql :: how to install mysql ubuntu 
Sql :: stop mysql 
Sql :: mysql where column not integer 
Sql :: output oracle 
Sql :: oracle columns in all_tables 
Sql :: mysql workbench download for iinux mint 19.3 
Sql :: disable foreign key constraint mysql 
Sql :: start mysql server by terminal in linux 
Sql :: liquibase alter column type / length 
Sql :: sqlite rename column 
Sql :: how to start mysql 
Sql :: rermove categories woocommerce sql 
Sql :: mysql where one year ago 
Sql :: get current month mysql 
Sql :: how to remove unique key constraint in mysql 
Sql :: how to copy a table from one database to another in mysql 
Sql :: sql drop primary key 
Sql :: how to check data type in sql server 
Sql :: oracle reset sequence 
Sql :: oracle failed login attempts 
ADD CONTENT
Topic
Content
Source link
Name
4+7 =