Home Tutorialhelp Comment Error in the Program

 
 

Comment

Kaushik patel
Error in the Program,
July 11, 2010 at 7:44 PM

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");
}
}
}

View All Comments | View Tutorial
Advertisement
Related Tutorial and Articles
Java Beginners

io
io  write a program in java to accept a filename from user and print... Scanner(System.in); 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 of the file will contain a multi-word query. The output of your program will be a text...IO in java  Your search mechanism will take as input a multi-word 

General

Delete file or Directory
or a directory by using a java program. We pass the file name or the directory name to which we want to delete. The given program deletes an existing file if the file... Delete file or Directory       

Programming Tutorials

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

Java-Tutorials

Moving file or directory from one directory to another
Moving file or directory from one directory to another... directory is moved from one directory to another directory. This program... from one directory to another. In this section an example is given 

Java Beginners

IO File - Java Beginners
IO File  Write a java program which will read an input file & will produce an output file which will extract errors & warnings. It shall exclude... from the log file. This is the task assigned to me..Please help me 

Java-Tutorials

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

Java Beginners

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

Java Beginners

java io
java io  Write a program to use a File object and print even numbers from two to ten. Then using RandomAccessFile write numbers from 1 to 5. Then using seek () print only the last 3 digits 

Java Tips and Examples

Java - Deleting the file or Directory
Java - Deleting the file or Directory   ... representation of file and directory pathnames.  Explanation This program deletes... is successfully deleted; false otherwise. delete() Deletes the file or directory 

Java Beginners

File copy from one directory to another in java
very good code example for copying a file from one directory to another directory in Java. I have to write a program in my application for copying one file... for copying the file from one directory to another directory in Java 

General

Delete a File
a specified file or directory is deleted. For deleting a file from a directory you need to give the file name to be deleted. Description of program: The following code of program deletes a file from a directory. In this program the compiler 

Java Beginners

io
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 

RMI Questions

ls: cannot access >: No such file or directory
/f.txt from terminal in linux its creating f.txt.But cant run from java program ls: cannot access >: No such file or directory error is displayed .No f.txt...ls: cannot access >: No such file or directory  import 

Java-Tutorials

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 Beginners

java IO
java IO  Write a Java program to accept a file name as command line argument. Append the string "File Modified by Programme" to the end of the same file and print the contents of the modified File 

Java Technology Tutorials

Java delete non empty directory
Java delete non empty directory This section demonstrates you how to delete a non empty directory. It is easy to delete a directory if it is empty by simply calling the built in function delete(). But if the directory is not empty 

General

Rename the File or Directory in Java
Rename the File or Directory in Java   ... a file or directory is renamed. This program illustrates you the procedure... otherwise file or directory will be moved from it's own directory to the default 

General

Delete temp file
: This program deletes a temp file from the current working directory which is created...;java DeleteTempFile Delete temp file example! Please enter file name... is deleted from the current working directory. Java provides deleteOnExit() method 

Java-Tutorials

Copy Directory or File in Java
will see how contains of a directory or a file is copied  from... then the program gives the output message like : File or directory does not exist... and destination directory or file name. Here is the code of the program :  

Java Beginners

How to delete a character from a file in java - Java Beginners
How to delete a character from a file in java  I'm not gettting how to remove a character from a file in java....could any one help me out?? .../beginners/ http://www.roseindia.net/java/example/java/io/ Thanks   I 

Java Beginners

java IO programing
java IO programing  how Java source file is used as input the program will echo lines 

Java Beginners

IO concept
IO concept  Write a java program that moves the contents of the one file to another and deletes the old file.   Hi Friend, Try...!"); } } For more information, visit the following link: Java Move File Thanks 

Java Tips and Examples

How to delete file in java ?
How to delete file in java ? In this section we will learn how to write a program to delete a file in java. You can delete the file or folder, java File.... Now, here is the code to delete a file in java. import java.io.File; public 

Java Beginners

java - file delete - Java Beginners
java - file delete  I will try to delete file from particular folder... following code to delete a file from the folder import java.io.File; public... will try to delete these files. But it doesn?t delete from this folder. My code 

Java Beginners

how to copy file from one directory to another in java with examples
how to copy file from one directory to another in java with examples  how to copy file from one directory to another in java with examples? I want a java with example code Thanks   Hi, Please check the thread File 

General

Java Example program to get the current working directory
Java Example program to get the current working directory       This example java program illustrates to get the current working directory (CWD). With the File class 

Ant

Ant make directory with relative path
;    This example illustrates how to make directory, how to compile java file and how to create jar file. This is a simple program...; is used to compile the java file and copy the class file in build directory 

Java Beginners

java program to read multiple files from a directory and display them on a jframe
java program to read multiple files from a directory and display them on a jframe  hi guys i want to write a java program that will read all files in a directory and display them one by on on a jframe on jpanel with specific key 

Java Tips and Examples

Java Directory - Directory and File Listing Example in Java
Java Directory - Directory and File Listing Example in Java...) of java.io package. In this example we are using File class of java.io.... Explanation This program list the file 

Java Beginners

java io
java io  by using java coding how to invoke a particular directory 

Java-Tutorials

Java Create Directory Example
Java Create Directory Example To create a directory in java call the mkdir..., to many directories in directory you need to call the mkdirs() mehtod. An example of creating a directory in java is given below SampleInterfaceImp.java import 

General

Get current working directory in Java
directory means the current working directory where java program execute. In java... to get current directory in Java with Example public class...Get current working directory in Java In this section we will discuss about 

Java-Tutorials

Command Line Standard Error In Java
the Command Line Java IO Standard Error. System.out and System.err both... or if the file doesn't existed in the specified directory then an error... this example and provide the file name (available in the specified directory) as I given 

Java-Tutorials

Directory and File Listing Example in Java
C:\nisha>java DirListing example myfile.txt... specified a directory name "example" that contains only a single file "myfile.txt". Download this example Example 

Java-Tutorials

Traversing a file and directory under a directory
then make an object of File class and pass any directory and filename to its constructor. After that, check it whether the file or directory you have entered is a directory or a file. If it is a directory then it will display 

Java Beginners

Java delete file if exists
Java delete file if exists  Hi, Hi how to delete file if exists? I need example code of java delete file if exists. Thanks   Hi, following code can be used: String tempFile = "C:/mydir/myfile.txt"; //Delete 

General

URL file Download and Save in the Local Directory
URL file Download and Save in the Local Directory       This Program file download  from  URL and save this Url File in the specified directory. This program specifies 

Java-Tutorials

Java IO File
Java IO File In this section we will discuss about the File class in Java... file or directory. Syntax : public boolean delete()   deleteOnExit... can also create a File to store the data. To create file in Java a class named 

Programming Tutorials

How to make directory in java
Description: This example demonstrate how to create a directory at specified...;new File("c:\\newDir");     file1.mkdirs();   } } Output: The result of this program 

Core Java

Java Create Directory
The following example will show how to Create Directory in Java. Though this can be created by using mkdir() also, the following program has used file object... is already created" will be displayed. Example of Java Create Directory 

Java Beginners

Create text file at client's directory from server.
Create text file at client's directory from server.  Need java code to create text file at client's directory from server..... Please Help 

Java Tips and Examples

Determining if a File or Directory exist
:\java>java FileOrDirectoryExists the file or directory you are searching... Determining if a File or Directory Exist   ... to determine whether a file or directory exists or not. If it exists it returns 

Java Tips and Examples

Java SDK Directory Structure
to combine C code into a Java program. Jre directory - When you run... Java SDK Directory Structure       This section introduces the Directory and file structure 

Java-Tutorials

Java IO Writer
Java IO Writer In this section we will discuss about the Writer class in Java... object of FileWriter to write the stream to the file. Further in the example I have... is created and contains the text written by the Java program. Source code 

Java Beginners

How to move a file from a directory to other directory
How to move a file from a directory to other directory  I tried the above example it will move the folder to other directory but it does not move the image file or other file to a specified directory. Can anyone help me? Thanks 

Java-Tutorials

Java IO PrintWriter
Java IO PrintWriter In this tutorial we will learn about the the PrintWriter... on console. PrintWriter is a character based class which makes the Java program easy... the PrintWriter in the Java applications. In this example I have created 

Java Beginners

reading multiple files from a directory and writing them into a single file
reading multiple files from a directory and writing them into a single file... file i get an empty text file can you guide me how to do this: /*this program reads multiple files * from a single directory. */ package elite.tech.com 

Java Beginners

java - file delete - Java Beginners
java - file delete  I will try to delete file from particular folder... will try to delete these files. But it doesn?t delete from this folder. My code...){ try { File delete = new File (incurrentFile); System.out.println 

Java Technology Tutorials

Java file delete fails
Java file delete fails This section demonstrates you how the deletion of file fails. Description of code: Sometimes you got an error that file deletion fails. There may be some reasons for this like the file you want to delete, does 

Java Tips and Examples

Determining if a Filename path is a file or a directory
. isDirectory(): It checks whether the file is a directory or not. getAbsolutePath(): It returns the absolute path of a file or directory. Code of the program is given... Determining if a Filename path is a file or a directory 

Java-Tutorials

Read Text from Standard IO
facilities for reading text from either the file or the keyboard on the command... Reading Text from the Standard Input   ... from the keyboard and write output to the display. They also support I/O 

Java-Tutorials

Java FileOutputStream Example
the text read from the abc.txt file will be written. Now created a Java class named...Java FileOutputStream Example In this section we will discuss about the Java... it clears the connections from the file and confirm that the close() method 

Java Technology Tutorials

How to download a file from URL in Java?
How to download a file from URL? If you are looking for example code in Java... is for you. You will learn how to write code in Java for downloading a file from URL.... This example can be used to download any type of file from URL. It can be text 

Java Beginners

java program - Java Beginners
information: http://www.roseindia.net/java/example/java/io/java-read-file-line...java program   Use antlr to write a program Grep for searching the input for a word: java Grep word [filename] The program reports the line number 

JDBC

Delete row and column from table through java code
Delete row and column from table through java code... will see how to delete row and column from given table through java code. Java code... 'Address'. Before running this java code you need to paste a .jar file named 

C Tutorials

C file delete example
C file delete example       This section illustrates you to delete a file in C. You can see in the given example that we want to remove the file HELLO.txt. For this, we have 

Java-Tutorials

Java Create Directory - Java Tutorial
Java Create Directory - Java Tutorial   ... a directory or subdirectories are created. This program also explains the process... class to crate the directory.  File The File class an abstract representation 

General

Example to compile a java file with the help of the program
Example to compile a java file with the help of the program... are describing you the way to compile the java file with the help of the java program. The steps involved for compiling the java file from the program are described 

Java Tips and Examples

Java Create Directory - Java Tutorial
will learn how to create directory using java program. This program also explains... Java Create Directory - Java Tutorial   ... will use the class File class to crate the directory. Class File The File class 

Java Beginners

java program
java program  write a java program to read a file content...; Please visit the following link: http://www.roseindia.net/java/example/java...) { System.err.println("Error reading file: " + e 

Java Beginners

How to read the data in text file seperated by by ',' in java using IO Operations
How to read the data in text file seperated by by ',' in java using IO Operations  in Text file data like raju 45,56,67 ramu 46,65,78 raji... the marks and sent the another text file like raju pass 67% ramu pass 56% raji fail 

Java Technology Tutorials

Java file delete
Java file delete In this section, you will learn how to delete a file... and call the method delete() through the object. This method delete the file from... delete the file from the given path name 

Java Beginners

java-io - Java Beginners
java-io  Hi Deepak; down core java io using class in myn...://www.roseindia.net/java/java-conversion/two-dimensional-array-program-using-nested-loop.shtml http://www.roseindia.net/java/beginners/SquareMatrix.shtml Thanks 

Java Technology Tutorials

Java file new directory
Java file new directory In this section, you will learn how to create a new directory. Description of code: This is a common task. The java.io.package... an object of File class and specify a directory which you want to create. Then we 

Java-Tutorials

Java IO InputStream Example
Java IO InputStream Example In this section we will discuss about... created a text file and write some texts into them. In the example I have... input stream as byte. Then after reading the data from the text file displayed 

Java Beginners

Import java IO - Java Beginners
Import java IO  for example i know java IO is for input and output. I am using Netbeans5.5.1. How can i see all the classes related to java IO for example; stream reader, buffer reader 

Java Technology Tutorials

Java count files in a directory
in the given example, we have created an instance of File class and specify a directory...Java count files in a directory In this section, you will learn how to count only files in a directory. You have learnt various file operations. Here we 

Java Tools

Delete a file from FTP Server
In this section you will learn how to delete file from FTP server using java 

Hibernate Questions

delete row from a table using hibernate
delete row from a table using hibernate  //code in java file String hql="delete from CONTACT c where ID=6"; Query query=session.createQuery... [delete from CONTACT] int i=query.executeUpdate 

JDBC

JDBC Delete Row In Table Example
JDBC Delete Row In Table Example : In this tutorial we will learn how delete... or more specific  row delete from table that follow any given condition...  Mysql query  "DELETE FROM user where user_id=1 "   

Java-Tutorials

Java IO OutputStreamWriter
"); bw.newLine(); bw.write("Java IO OutputStreamWriter Example...Java IO OutputStreamWriter In this section we will learn about the Java... tried to write the data to a file. So, when you will executed this example 

Java Technology Tutorials

Java file get parent directory
Java file get parent directory In this section, you will learn how to get the parent directory of the file. Description of code: The package java.io.... and directories. You can see in the given example we have created a File object 

JDBC

JDBC Delete All Rows In Table Example
JDBC Delete All Rows In Table Example:  In this tutorial provide the example of  how to delete  all records from table using mysql ... query and   execute. There use mysql query "DELETE FROM user" 

General

Java error reading from file
Java error reading from file       Java error reading file... In this Tutorial we help you in understanding a n example from Java error 

Java-Tutorials

Java IO FilterWriter
Java IO FilterWriter In this example we will discuss about the FilterWriter...(); bw.write("Java IO FilterWriter Example"); System.out.println("Data is written... an example is being given which demonstrates about how to use Java FilterWriter 

Java-Tutorials

Java Io BufferedWriter
Java IO BufferedWriter In this section we will discuss about... will be written to the new file. For this I have created a Java class named... Before executing the above example a file (say, as abc.txt is in this example 

Java Beginners

java error - Java Beginners
java error  Hello sir, on compiling any program from command prompt.... But if I want to run that program the fetches me the following error. For example for file: Test.java C:\Program Files\Java\jdk1.6.0_17\bin>javac Test.java 

Java Beginners

How to write file from inputstream in java
How to write file from inputstream in java  Hi, how to write file from inputstream in java program. Plz suggest an example or suggested link... link to your query "How to Write to inputStream in Java". This is good 

Java Beginners

Directory chooser in core java - Java Beginners
[]) { JFrame frame = new JFrame("Directory chooser file example"); FileChooser...Directory chooser in core java  Hi, I have to create a Utility which will copy files from a source folder to the any other folder. For same I want 

Java Technology Tutorials

How to delete files in Java?
, we use the delete() function to delete the file. Given below example... Delete a File using File Class Object       Delete a File using File Class 

Java Beginners

Java File Management Example
for a good program to download the data from ftp server and then read the file one line... of file. Read the example Read file in Java for more information on reading the file one line at at time. You can write program for downloading the file from ftp 

Java-Tutorials

Java IO SequenceInputStream Example
Java IO SequenceInputStream Example In this tutorial we will learn about... in the sequence of files in which they are ordered i.e. reads the first file until reached at end the of file and then reads another file until reached at the end 

Java-Tutorials

Java IO CharArrayWriter
Java IO CharArrayWriter In this tutorial we will learn about the CharArrayWriter in Java. java.io.CharArrayWriter extends the java.io.Writer.... the characters, and write the data to the file. For this in the example I have used 

Java Beginners

io - Java Beginners
io  how to give the input like integer data,float data from the keyboard pls give me the information along with the example  Hi friend.... http://www.roseindia.net/java/ Thanks Amardeep 

Java Beginners

java io - Java Beginners
Java IO Streams  What is the Java IO Stream 

Java Beginners

How to Write to file in Java?
How to Write to file in Java?  How to Write to file in Java Program?   Hi, For writing a file in Java, we need some classes from Java.IO... the Examples of How to write to File in Java Program: WriteToFileExample.java import 

Hibernate Questions

Hibernate delete a row error - Hibernate
delete example (http://www.roseindia.net/hibernate/hibernate-delete.shtml...(); //======================================= sess = fact.openSession(); String hql = "delete from Contact contact... ehcache from ehcache-failsafe.xml found in the classpath: jar:file:/C:/Software 

Java Beginners

Delete specific lines from text in Java
Delete specific lines from text in Java  Hi, beginning in java, i'm trying to delete specific line from a text file. Ex: i want to delete data... number that i want to delete. how could it be possible with java. thanks a lot 

Java Interview Questions

Java IO
Java IO  What an I/O filter 

Java Beginners

Java compilation error - Java Beginners
. For example if java is installed at c:\Program Files\Java\jdk1.6.0_01...Java compilation error  Hello, i am getting an error while running simple core java program on command prompt.java is installed on my pc 

Java-Tutorials

Java FileInputStream
Java FileInputStream In this section we will discuss about the Java IO... for reading the input bytes from a file. An InputStream is a super class... already created in the current directory. If the file is located outside 

JSP Servlet Questions

Delete and edit data in xml file using JSP
Delete and edit data in xml file using JSP   I want to know how to delete and edit data from an XML file by use of JSP. I have XML file having tasks... in the xml file,I want to delete and edit some tasks using task id then how can i do 

Java-Tutorials

Java IO OutputStream
Java IO OutputStream In this section we will read about the OutputStream class... to the specified file. In this example I have tried to read the stream of one file... will not create the write.txt file before execution of the program 

Java Tools

FTP Server : Remove Directory
In this section you will learn how to delete directory on FTP server using java 

Java Interview Questions

delete a node from singly linked list in java
delete a node from singly linked list in java  Write a program(in java), if given a pointer to a node (not the tail node) in a singly linked list, delete that node from the linked list.   could you tell your question 

JDBC

Delete a Column from a Database Table
\jdbc\jdbc\jdbc-mysql>java DeleteColumn Delete columns example... Delete a Column from a Database Table   ... to delete a column from a database table. We are not going to create a new table 

Swing AWT

How to delete records from jtabel - Swing AWT
How to delete records from jtabel  hello I am using jtabel.... It is working properly.but now i want to delete rows from tabel at a time one row...); } } ------------------------------ read for more information, http://www.roseindia.net/java/example/java/swing 

Java-Tutorials

Java IO FileReader
of this example can be downloaded from the link given below. The downloaded file...Java IO FileReader In this tutorial we will learn about the FileReader class... you about how to use java.io.FileReader. In this example I have created a Java 

Advertisements Advertisements
 

 

 

DMCA.com