Java tutorial
//package com.java2s; import java.io.File; import java.io.IOException; public class Main { public static File getFile(String path) throws IOException { String dirPath = path.substring(0, path.lastIndexOf(File.separator)); File dirFile = new File(dirPath); File file = new File(path); if (!dirFile.exists()) dirFile.mkdirs(); if (!file.exists()) file.createNewFile(); return file; } }