Here you can find the source of getUploadPath(String fileName, long time)
public static String getUploadPath(String fileName, long time)
//package com.java2s; //License from project: Apache License import java.io.File; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static String getUploadPath(String fileName, long time) { SimpleDateFormat formater = new SimpleDateFormat("yyyy/MM/dd"); String uploadPath = "/upload/" + formater.format(new Date()) + "/" + time + getFileExt(fileName); File dir = new File(getWebRoot() + uploadPath); if (!dir.exists()) { try { dir.mkdirs();/*from ww w . j ava 2s. co m*/ } catch (Exception e) { e.printStackTrace(); return ""; } } return uploadPath; } public static String getFileExt(String fileName) { return fileName.substring(fileName.lastIndexOf(".")); } public static String getWebRoot() { File f = new File(""); return f.getAbsoluteFile().getAbsoluteFile().getPath(); } }