creation of a file along with the current time.....please help me out...!

myfolder is my directory name in E drive

 Date date1 = new Date();
 DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss");
 String fileName = dateFormat.format(date1);
 File file = new File("E://"+"myfolder/"+fileName+".txt")`

Answers


As pointed in comments, you can't use colons.

The other problem is that you expect that new File will create the file in your directory. It won't, it's just an abstract representation of it.

You can call createNewFile to create it on your disk.

I.e :

Date date1 = new Date();
DateFormat dateFormat = new SimpleDateFormat("HH-mm-ss");
String fileName = dateFormat.format(date1);
File file = new File("C://Temp//"+fileName+".txt"); //created in temp to see
if(file.createNewFile()){
    System.out.println("created");
} else {
    System.out.println("not created");
}

Need Your Help

Adding options to select with javascript

javascript html

I want this javascript to create options from 12 to 100 in a select with id="mainSelect", because I do not want to create all of the option tags manually. Can you give me some pointers? Thanks

Detecting and writing when client side disconnects

c# sockets client-server disconnect

im writing a simple Client/Server application in C#.