Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import java.io.File;

public class Main {
    private static void makeDirs(String fileName) {
        // get the last / or \ position, return if not found
        int lastSlashPos = fileName.lastIndexOf("/");
        if (lastSlashPos == -1) {
            lastSlashPos = fileName.lastIndexOf("\\");

            if (lastSlashPos == -1) {
                return;
            }
        }

        String folderPath = fileName.substring(0, lastSlashPos);
        File folderFile = new File(folderPath);
        folderFile.mkdirs();
    }
}