Link to home
Start Free TrialLog in
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

ASKER CERTIFIED SOLUTION
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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.
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)
Avatar of AndyC1000
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.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
:)