Here you can find the source of createTodayDirectory(File destDir, String inputFileName)
Parameter | Description |
---|---|
destDir | the dest dir |
inputFileName | the input file name |
public static final File createTodayDirectory(File destDir, String inputFileName)
//package com.java2s; /* (c) 2014 Open Source Geospatial Foundation - all rights reserved * This code is licensed under the GPL 2.0 license, available at the root * application directory./* ww w . j av a 2 s .c o m*/ */ import java.io.File; import java.text.SimpleDateFormat; import java.util.Date; public class Main { /** * Creates the today directory. * * @param destDir * the dest dir * @param inputFileName * the input file name * @return the file */ public static final File createTodayDirectory(File destDir, String inputFileName) { return createTodayDirectory(destDir, inputFileName, false); } /** * Creates the today directory. * * @param destDir * the dest dir * @param inputFileName * the input file name * @param withTime * the with time * @return the file */ public static final File createTodayDirectory(File destDir, String inputFileName, final boolean withTime) { final SimpleDateFormat SDF = withTime ? new SimpleDateFormat("yyyy_MM_dd_hhmmsss") : new SimpleDateFormat("yyyy_MM_dd"); final String newPath = (new StringBuffer(destDir.getAbsolutePath().trim()).append(File.separatorChar) .append(SDF.format(new Date())).append("_").append(inputFileName)).toString(); File dir = new File(newPath); if (!dir.exists()) { dir.mkdir(); } return dir; } }