Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

problem in creating a new file  RSS feed

 
rahul karwal
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1511
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Apparently, your JDK must not be 1.2 or above. Method createNewFile() is only available since java 2 (JDK 1.2 or higher)
Bosun
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!