Here you can find the source of createTodayPrefixedDirectory(final String prefix, final File parent)
Parameter | Description |
---|---|
prefix | the prefix |
parent | the parent |
public static File createTodayPrefixedDirectory(final String prefix, final File parent)
//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.//www . j ava2 s .c o m */ import java.io.File; import java.text.SimpleDateFormat; import java.util.Date; public class Main { /** * Creates the today prefixed directory. * * @param prefix * the prefix * @param parent * the parent * @return the file */ public static File createTodayPrefixedDirectory(final String prefix, final File parent) { final SimpleDateFormat SDF_HMS = new SimpleDateFormat("yyyy_MM_dd_hhmmsss"); final String newPath = (new StringBuffer(parent.getAbsolutePath().trim()).append(File.separatorChar) .append(prefix).append(File.separatorChar).append(SDF_HMS.format(new Date()))).toString(); File dir = new File(newPath); if (!dir.exists()) { dir.mkdirs(); } return dir; } }