aspose file tools*
The moose likes Beginning Java and the fly likes problem in creating a new file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "problem in creating a new file" Watch "problem in creating a new file" New topic
Author

problem in creating a new file

rahul karwal
Ranch Hand

Joined: Oct 26, 2001
Posts: 73
hi ppl,
i am trying to create a file given the name of the file at command line but when i try to compile its giving me an error saying createNewfile() method not found in class java.io.File. i dont know why please help me......
thank u
import java.io.File;
public class createfile{
public static void main(String[]args){
String name = args[0];
File file = new File(name);
file.createNewFile();
boolean cheak = file.exists();
System.out.println(cheak);
}
}
Bosun Bello
Ranch Hand

Joined: Nov 06, 2000
Posts: 1510
Apparently, your JDK must not be 1.2 or above. Method createNewFile() is only available since java 2 (JDK 1.2 or higher)
Bosun


Bosun (SCJP, SCWCD)
So much trouble in the world -- Bob Marley
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: problem in creating a new file