As you can see, right now, I am writing a file named
employee_status_downloader_unixtimestamp.csv in an already created directory on RHEL server as shown in this line of code below:
So, I manually created a folder named JACK and then specified the above path so that the files related to the
userName JACK are inside JACK folder.
Since the
userName can be different and I am already getting the
userName in my method above from this line of code
String userName = parts[1].trim();, I am wondering if I could make use of this
to create a directory based on the
userName?
So, I am not using
System.getProperty("user.name"); here since I am already getting
userName in my method above.
After looking online , I found that people are suggesting to do something like this :
File fl = new File("/path/directory").mkdirs(); where directory is the name of the directory I want to create/exist. But since I am using FileWriter above, I am wondering how should I go about using both so that
I could also create a directory if it doesn't exist and then write a file in the directory.
References:
Bozho's answer:
https://stackoverflow.com/questions/3634853/how-to-create-a-directory-in-java