Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import android.os.Environment;

import java.io.*;

public class Main {
    static public String prepareFilePath(String fileName, String dir) throws IOException {
        File dictionaryRoot = new File(Environment.getExternalStorageDirectory(), dir);
        File dictionaryDirFile = new File(dictionaryRoot, fileName.substring(0, 1));
        if (!dictionaryDirFile.exists()) {
            if (!dictionaryDirFile.mkdirs()) {
                throw new IOException("Cannot create directory: " + dictionaryDirFile);
            }
        }
        return new File(dictionaryDirFile, fileName + ".mp3").getCanonicalPath();
    }
}