The moose likes I/O and Streams and the fly likes Problem with creating a file in the current directory and with the current time stamp Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » I/O and Streams
Reply Bookmark "Problem with creating a file in the current directory and with the current time stamp" Watch "Problem with creating a file in the current directory and with the current time stamp" New topic
Author

Problem with creating a file in the current directory and with the current time stamp

linda russel
Ranch Hand

Joined: Jan 05, 2012
Posts: 73



In the above code i have created a new folder under the testresults folder. but i want to create the same in current directory. how do i specify the current directory as path?

and how do i name the created folder with current timestamp?

are there any methods??
linda russel
Ranch Hand

Joined: Jan 05, 2012
Posts: 73



i tired with the following code without success
Swastik Dey
Ranch Hand

Joined: Jan 08, 2009
Posts: 990

Reason is a file name can't contain the following characters in windows

*\:/?<>"|


Swastik
linda russel
Ranch Hand

Joined: Jan 05, 2012
Posts: 73
what is the workaround then?
Swastik Dey
Ranch Hand

Joined: Jan 08, 2009
Posts: 990

May be you could format that datetime in some other way, that doesn't contain those characters.
linda russel
Ranch Hand

Joined: Jan 05, 2012
Posts: 73
ok thanks.
linda russel
Ranch Hand

Joined: Jan 05, 2012
Posts: 73


why it didnt create for the following??
Rob Spoor
Saloon Keeper

Joined: Oct 27, 2005
Posts: 18376

Your parent path doesn't end with a \. That means that your path is something like C:\\Users\\linda\\workspace\\febtemporary\\src2012-02-06_02-39-15. It wouldn't surprise me if that actually exists now.


SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
linda russel
Ranch Hand

Joined: Jan 05, 2012
Posts: 73
Thanks Rob


I corrected with the following line of code




linda russel
Ranch Hand

Joined: Jan 05, 2012
Posts: 73



finally the following code worked fine. am happy with it. but i want a slight modification. how do i store my screenshots inside the dynamically created folders
 
 
subject: Problem with creating a file in the current directory and with the current time stamp
 
Threads others viewed
Help with Files
File I/O
What is the method to get the current directory(please read)
renameTo()
IO
WebSphere development made easy
without the weight of IBM tools
http://www.myeclipseide.com