User Comments for the tutorial:

Delete a File

Total comments: 4      View Tutorial    Discuss: Delete a File



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

Program is for create a new file
file.createNewFile() should be replaced as file.deleteFile(). 

Java already has a method to remove file
Java already has a method to remove file File f = new File("filename"); f.delete();  

Error in the Program
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; import*; public class DeletingFile { public static void main(String args[])throws IOE 

Related Tutorial and Articles
Java Beginners

io  write a program in java to accept a filename from user and print... Scanner(; System.out.println("Enter file: "); String str=input.nextLine(); File file=new File(str); FileReader fr=new 

Java Beginners

IO in java
the directory as before along with a file containing a set of queries. Each line...IO in java  Your search mechanism will take as input a multi-word... the words specified appear closer to one another. For example, if you search 

Java Beginners

java binary file io example
java binary file io example  java binary file io example 

Programming Tutorials

Working With File,Java Input,Java Input Output,Java Inputstream,Java io Tutorial,Java io package,Java io example
. The instance of this class represents the name of a file or directory on the host file... to the existence of a corresponding file/directory. If the file exist, a program can... it, deleting it, reading from or writing to it. The constructors of the File class 


Delete file or Directory
Delete file or Directory      ... or a directory by using a java program. We pass the file name or the directory name to which... the delete() on this file, If it is not a file then we check for the directory and also 


Moving file or directory from one directory to another
Moving file or directory from one directory to another... from one directory to another. In this section an example is given...; If you want to move file or directory from other directory 

Java Beginners

io  create a meanu based text editor in java having features of creating file,viewing file,deleting file,renaming file,copying file and cutting file 


Java IO Path
called the delimiter. The file separator varies from O/S to O/S for example... a file uses the complete directory path from root node to file is an absolute... not contains the complete directory path from root node to the file which has 

Java Beginners

Getting Current Directory from java - Java Beginners
Getting Current Directory from java  I'm designing an application in linux where i need to get the current directory of my java file... I'm using.../example/java/io/GetCurrentDir.shtml Thanks 


Java - Deleting the file or Directory
deleted; false otherwise. delete() Deletes the file or directory denoted... Java - Deleting File      ... of file and directory pathnames.  Explanation This program takes