Avatar of AndyC1000
AndyC1000
 asked on

Create folder with timestamp

Dear all,

I'm using FileWriter to create a file. I want to create a folder in the outputPath with the timestamp and write the file to this location.

I'm not sure how to go about this.
Thanks

String outputFilename = "result";
String outputPath = "output/";

Writer writer = new FileWriter(outputPath + outputFilename + i + ".csv", true);

Open in new window

Java

Avatar of undefined
Last Comment
CEHJ

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
CEHJ

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Jeffrey Dake

You could use what CEHJ has recommended, however how exactly do you want the directories created. Are you looking for one directory per day?  If so you use Calendar with a date formater to format what you are trying to do.

This would probably be more useful then a new directory with the millisecond in it. That is not very human readable for the future.

Hope that helps.
CEHJ

There are actually more important considerations than readability: for instance, why would you want a folder with a timestamp as its name?
Are you putting more than one file into it? If so, then you're likely to need a coarser granularity than a timestamp with milliseconds or possibly even seconds (maybe even coarser)
AndyC1000

ASKER
The purpose of the folder is to store the date/time of the model run, I will need to record time down to seconds.
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
SOLUTION
CEHJ

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
CEHJ

:)