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 {
    public static File createFileInSDCard(String path, String fileName) {
        File dir = new File(path);
        try {
            if (!dir.exists() && dir.mkdirs()) {
                System.out.println("Directory created");
            } else {
                System.out.println("Directory is not created");
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        File file = null;
        try {
            if (dir.exists()) {
                file = new File(dir, fileName);
                file.createNewFile();
            } else {

            }
        } catch (Exception e1) {
            e1.printStackTrace();
        }
        return file;
    }
}