Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Spring Framework | Web Services | BioInformatics | Java Server Faces | Jboss 3.0 tutorial | Hibernate 3.0 | XML

Tutorial Categories: Ajax | Articles | JSP | Bioinformatics | Database | Free Books | Hibernate | J2EE | J2ME | Java | JavaScript | JDBC | JMS | Linux | MS Technology | PHP | RMI | Web-Services | Servlets | Struts | UML


 

Java Tutorials


 

 

Struts Tutorials

Struts Resources

Visit Forum! Post Questions!
Jobs At RoseIndia.net!

Java Example Java Io Delete File From Directory

User Comments
Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl
  Blink   Furl   Simpy   Y! MyWeb 

Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 

Current Comments

4 comments so far (post your own) View All Comments Latest 10 Comments:

In the program u have not mentioned any delete() function so how can it be able to delete the file....please update the code

import java.io.File;
import java.io.*;

public class DeletingFile {
public static void main(String args[])throws IOException{
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
System.out.print("Enter the file name to delete:");
String file_name = in.readLine();
File file = new File("file_name");
boolean exist = file.exists();
if (!exist){
System.out.println("File was not exist....\n");
} else {
if(file.delete())
{
System.out.println("File successfully deleted....\n");

}
else
System.out.println("File was not successfully deleted.\n");
}
}
}

Posted by Kaushik patel on Sunday, 07.11.10 @ 19:44pm | #98110

Java already has a method to remove file

File f = new File("filename");
f.delete();

Posted by okan on Monday, 05.31.10 @ 02:19am | #97280

file.createNewFile() should be replaced as file.deleteFile().

Posted by Divya on Monday, 06.1.09 @ 10:45am | #88167

The above code is totally wrong, so correct it!!!

Posted by Vipin Paliwal on Wednesday, 09.10.08 @ 13:50pm | #78494

Ask programming questions?

 

 

Back to Tutorial

 

  JDO Tutorials
  EAI Articles
  Struts Tutorials
  Java Tutorials
  Java Certification

Tell A Friend
Your Friend Name

 

 
Browse all Java Tutorials
Java JSP Struts Servlets Hibernate XML
Ajax JDBC EJB MySQL JavaScript JSF
Maven2 Tutorial JEE5 Tutorial Java Threading Tutorial Photoshop Tutorials Linux Technology
Technology Revolutions Eclipse Spring Tutorial Bioinformatics Tutorials Tools SQL
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright 2007. All rights reserved.