0

This is a homework question. I have a shell script in which i am creating a folder structure .Then i am giving a call to java program where i am extracting data from a table writing it into the file and want to place the file to that folder. The folder structure changes everyday. as let suppose the folder structure like Logs/Month/day and i am creating that everyday. How can i place the data file to the particular folder.

Ex. I have a_20131216.log to be placed in logs/12/16 a_20131215.log to be placed in logs/12/15

  • by creating File to that directory path - http://stackoverflow.com/questions/3634853/how-to-create-a-directory-in-java/3634906#3634906 similar to this – jmj Dec 17 '13 at 17:43
  • jigar thanks for your reply . i am creating folder through script. how can i copy the file created to that folder location. that also everyday changing location. – user3112259 Dec 17 '13 at 17:51
  • you could use mv (move) or cp (copy) command in bash script to move / copy file or in java you can generate same directory path and move/copy it to that location Directly using `FileUtils` http://commons.apache.org/proper/commons-io/apidocs/org/apache/commons/io/FileUtils.html – jmj Dec 17 '13 at 17:53
  • ok will try to use the apache FileUtils. Thanks Jigar – user3112259 Dec 17 '13 at 18:02
  • when you get it answered please answer it by yourself and accept it for other's reference – jmj Dec 17 '13 at 18:04

1 Answers1

1

Look at

  • the date command to create the directory name.
  • the -p option to mkdir
glenn jackman
  • 238,783
  • 38
  • 220
  • 352