This week's giveaway is in the Spring forum.
We're giving away four copies of Learn Spring Security (video course) and have Eugen Paraschiv on-line!
See this thread for details.
Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

problem in creating a new file

 
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: 1510
  • 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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic