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 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 

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 

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 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 

SQL Question

DELETE
DELETE   I AM DOING IT IN MYSQL. DELETE FROM EMP WHERE SAL>(SELECT SAL FROM EMP WHERE ENAME='MILLAR') AND ENAME='ALLEN'; THIS IS GIVING THE FOLLOWING ERROR Error Code : 1093 You can't specify target table 'EMP 

Java Interview Questions

Java IO
Java IO  What an I/O filter 

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 Beginners

io packages - Java Beginners
io packages  How can I add two integers in java using io pacages 

JSP Servlet Questions

Delete image from folder - JSP-Servlet
Delete image from folder  Hi Thanks Rajnikant to given me reply i am not storing my image in db just userid comming from db means my... + photoname; System.out.println(path); new File(path).delete(); } } hope 

Java-Tutorials

Deleting row and column from a table
Deleting row and column from a table  In this program ,we delete row... connection interface and java driver. After it we can delete row using "delete...) from cellular");     rs.next();              // This sql query delete 

General

Display list of files from a directory using Java
Display list of files from a directory using Java In this section, you will learn how to display the list of files of a particular directory or a sub...() method display the list of file names of that directory and if it is having any 

Java Beginners

how to copy the directory in to ftp server using java
the directory in to ftp server using java ?   Hello venaktehs As much... directory.For example : ftp.setLocalDir(new File("C:/tmp"); Now you can upload file in your remote directory as follows : ftp.upload(new File("c:/tmp/test.txt 

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

copy file from folder to folder - Java Beginners
copy file from folder to folder   my requirement is I need to copy xml files from one folder to another my source file contains the field filename wich contains the file to be copied. I want to copy the file from 

Programming Tutorials

Java Telephone directory management system
Java Telephone directory management system Here we are going to create a java application for Telephone directory system. For this, we have accepted ID, name... new ClassCastException("Error"); int ide = ((Directory) ob).getId 

JSP Servlet Questions

Error 500-Server are not find the jar file in the program of upload the file - JSP-Servlet
Error 500-Server are not find the jar file in the program of upload... the URL from the address bar again. Even though the 500 Internal Server Error... a program to upload a file.I include the commons-fileupload-1.2.1.jar file in lib 

PHP Tutorial

Delete Cookie
Delete Cookies In the following program, you will learn how to delete the cookie through setting session.  In the given example, we have set the value... to get two output from this program, first we gave $_cookie () to view only one 

JSP Servlet Questions

Delete image from folder - JSP-Servlet
Delete image from folder  Dear All, i used some coding... some time its burden for server. so dear friends i want to delete that image when user will logout using java code. anybody having idea about then please 

Java Beginners

Character from text file - Java Beginners
Character from text file  Write a program that reads characters from a text file. Your program will count how many time each character appear in the text. Assume that the letters are case-sensitive. Example output 

JSP Servlet Questions

Java compilation error - JSP-Servlet
, when the report is called from the database for "viewing" purpose, the file...; ^ Generated servlet error: C:\Program Files\Apache Software Foundation...; ^ Generated servlet error: C:\Program 

Servlet Interview Questions

java compilation error - Servlet Interview Questions
:\program file\java\jdk1.6.0). You can either set this from the command prompt...java compilation error  when i compile my servlet java file i get the compilation error as import java.servlet.* not found  servlet 

PHP Tutorial

Creating a File in the directory.
Creating a file using HTML form action In this example, you will learn to make a query form asking to to create a file in PHP. You will have to write... the file name and end the php cide.  Example: <?php if($_POST[" 

JDBC Questions

java runtime error - JDBC
java runtime error  when i am running my jdbc program using thin driver this error is coming at runtime: Exception in thread "main... to this : Thrown when the Java Virtual Machine attempts to read a class file 

Java Beginners

java program example - Java Beginners
java program example  can we create java program without static and main?can u plzz explain with an example 

JSP Servlet Questions

delete
= conn.createStatement(); st.executeUpdate("DELETE FROM employee WHERE empid...delete  how delete only one row in the database using jsp.database...); String query = "select * from employee"; st = con.createStatement 

Java Beginners

java program for writing xml file - Java Beginners
java program for writing xml file  Good morning i want to write values from my database(one table)into one xml file. Like i have 3 coloumns in my... xml file and storet that in particlar location. Please help me out Thanks 

Java Beginners

Program to read a dynamic file content - Java Beginners
Program to read a dynamic file content  Hi, In a single... the database. Im using MySql Database and a standalone java program. I.... For example: Folder name "Sample". Inside that "010209.txt 

Java Beginners

execution of image example program - Java Beginners
execution of image example program  sir. The example for the demo of image display in java,AwtImage.java,after the execution I can see only the frame... an existing image file in the pc, kindly suggest solutions....  Hi friend 

Java Beginners

How to format text file? - Java Beginners
/example/java/io/java-read-file-line-by-line.shtml Thanks... ***(Java code) How to open,read and format text file(notepad) or MS-word document in the same directory that of this required java program????  Hi 

Java Beginners

File Handling - Java Beginners
"); } } } I have few files in that directory.. my need is to select one file and write few datas and close the file... when i select a file for first time the program... that file i can see that text what i typed in comsole window.. If i run my program 

Java Beginners

: Java Compilation error. - Java Beginners
: Java Compilation error.  what is the difference between static... instance. Static Block is executed when the Program starts. Example... from another static class or method Example : public class StaticExample 

Java Beginners

Setting File Attributes
is the example of making a file hidden from Java program. Runtime.getRuntime().exec("attrib +H myHiddenJavafile.java"); You make a file read only from Java program. Here..., There is no API to make a file hidden in Java. To make a file hidden from the java 

Java Beginners

i written the program in the files but in adding whole file is writing once again - Java Beginners
i written the program in the files but in adding whole file is writing once again  Very Urgent: Write a small record management application file... From Database Id Name Last Name Delete 

Java Beginners

Error While Compiling - Java Beginners
command, operable program or batch file. C:\javatutorial\example>  ...Error While Compiling  Hi All I Am a beginner and i face...;. or try to set the path in envirnment variable..ok.. example set path 

General

Search word from text file using Java
How to Search word from text file using Java In this section, we are going to search a word from the text file. For this, we have created a swing button... from the text file. Here is the code: import java.io.*; import 

JSP Servlet Questions

file upload error - JSP-Servlet
file upload error  Hello friends, In my project when i am trying to upload a file i used the roseindia.net coding from URL: http... understood that this error occurred because of a jar file missing. But, i am 

JSP Servlet Questions

file upload error - JSP-Servlet
----------- file upload example...file upload error  Iam doing jsp project. File uploading is one part of the project. In this particular part i got an error 

Java Beginners

Java Program - Java Beginners
Java Program  Write a program to store and read the data of a student(s) in & from a file named ?STUD.DAT?. The student?s data consists of name... or modifying existing data, displaying the existing data from a file. Please 

Java Beginners

File Handling - Java Beginners
File Handling  I have written one program by which we can create...("File create and write example."); BufferedReader buff = new BufferedReader(new...) { System.err.println("Error writing to file 

Java Beginners

runtime error - Java Beginners
runtime error  sir run time error is coming again in this code also null pointer Exception at for( File f:contents) import java.io.*; public... path="C://RECYCLER//S-1-5-21-1004336348-1364589140-725345543-500";; File folder 

JSP Servlet Questions

Java Compilation error - JSP-Servlet
folder and from where i got file commons-fileupload-1.2.1.jar. in which all classes reside. i copy that file into C:\Program Files\Apache Software Foundation...-fileupload-1.2.1.jar but still there is a problem and when i compile my file this error 

JSP Servlet Questions

file upload error - JSP-Servlet
file upload error  Iam doing jsp project. File uploading is one part of the project. In this particular part i got an error...: org/apache/commons/io/output/DeferredFileOutputStream 

Java Beginners

error message - Java Beginners
error message  sir, while i m trying to execute my first program(print my name)I get error message like" javac is not recognized as internal...;Hi friend, To compile and run a java program we need to install java 

Java Beginners

runtime error - Java Beginners
file: " + f); } else System.out.println("Cannot delete: " + f... file: " + f); } else System.out.println("Cannot delete: " + f..."); } public static void deleteContentsInFolder(String path) { File folder = new 

Applet Questions

Java Program - Applet
Java Program  A java program to move a text in applet from right to left.  Hi Friend, Please visit the following link: http://www.roseindia.net/java/example/java/applet/SampleBanner.shtml Thanks 

Java Beginners

file arraival in java - Java Beginners
file arraival in java  A simple java program that runs continuously as a background process and prints out according to a given event based schedule(Arrival of a file in a specified directory) and is exited only through manual 

Applet Questions

java compilation error - Applet
java compilation error  hi friends the following is the awt front design program error, give me the replay E:\ramesh>javac...://www.roseindia.net/java/example/java/awt/ Thanks 

Java Beginners

Setup file - Java Beginners
Setup file  Hello sir ,how i can make Java Programs Set up File... to be printed. For instance in the above example we have used - throw new.... Point to note here is that the Java compiler very well knows about 

Programming Tutorials

How do Unzip a directory and all its contents using ZipEntry class in java.
file is directory then returns true otherwise returns false. In this Example...How do Unzip a directory and all its contents using ZipEntry class in java... method of ZipEntry class check given file is directory or not.The getName method 

JSP Servlet Questions

Generated java file - JSP-Servlet
to compile class for JSP: An error occurred at line: 7 in the generated java file Syntax error on token ";", delete this token... will be translated as JAVA SERVLET files. I got this error at run time 

Java Beginners

Java compilation error - Java Beginners
that the file could not open for writing the filename or directory name of volume...Java compilation error  Hello I am having this problem while compiling I create a file the package is com.deitel.ch14; the filename 

Java Beginners

why to create directory structure as web-inf & classes & lib - Java Beginners
? actually what internally the process will be take place from this directory structure...why to create directory structure as web-inf & classes & lib    we... e)providing deployment descriptor (web.xml) as part of WEB-INF directory 

Java Beginners

why to create directory structure as web-inf & classes & lib - Java Beginners
? actually what internally the process will be take place from this directory structure...why to create directory structure as web-inf & classes & lib    we... e)providing deployment descriptor (web.xml) as part of WEB-INF directory 

Java Beginners

java program - Java Beginners
java program   Pl. let me know about the keyword 'this' with at least 2 or 3 example programs. pl. let me know the program to multiply 2 matrix... 'this' is useful when you need to refer to instance of the class from its method 

PHP Tutorial

PHP Variables from File
PHP Variables from File Today we will learn about fopen() function in php. fopen() function is used to open the file directly from the C directory or URL... for open a particular file and the mode of opening the file. For example 

Java Beginners

read excel file from Java - Java Beginners
read excel file from Java  How we read excel file data with the help of java?  Hi friend, For read more information on Java POI visit to : http://www.roseindia.net/java/poi/ Thanks 

General

Insert and Delete an element in between an array
Insert and Delete an element in between an array In this section, you will learn how to insert and delete an element in between an array. For this purpose, we... code remove an element from an array: public int[] deleteFromArray(int index 

Java Beginners

JAVA PROGRAM - Java Beginners
JAVA PROGRAM  write a program to find the largest word from given sentence ?(WITHOUT USING tokenizer AND ARRAY) for example- input-- ram is intelligent boy. output will be--intelligent   Hi Friend, Try 

Java Beginners

Servlet error - Java Beginners
..??  Hi Friend, You can simply save your java file in classes...;Cont.. Then your java file and its class file, both get placed in the classes... program will work. By simply keeping the file in class folder will not make any 

PHP Tutorial

PHP list contents of directory
Contents of a directory or a folder can be displayed one by one. readdir() function returns the directory as well as file name. readdir() takes input... Constents of Directory <?php $file=opendir("c:\apache-ant-1.7.1-bin 

Java Interview Questions

Error Opening File - Java Interview Questions
this generated file, a message was displayed: Error opening file. But If I...Error Opening File  Dear, Please if help me to resolve this problem. I have an application in java that works correctly under Eclipse 

Java Beginners

File transfer
File transfer  Hi there... I would like to know is it possible to transfer files from one directory to another with out file io operations 

JavaMail Questions

java complilation error - JavaMail
java complilation error  Hi I was trying to send the mails using...   Hi, just download the "ant-javamail.jar" from.../Downloadantjavamailjar.htm and add this jar file into the lib folder in ur netbeans 

Java Beginners

Java Program HELP - Java Beginners
Java Program HELP  Hi I'm having trouble with this program, i keep getting errors. Can you help me. Thanks Write a program to create a file named... from 1 to 100, separated by a comma. After the file has been created, close 

Java Beginners

java runtime error - Java Beginners
and set the following: JAVA_HOME=C:\Program Files\Java\jdk1.6.0; Path=C:\Program Files\Java\jdk1.6.0\bin; Thanks  Hello Friend, I am thankful...java runtime error  import java.io.*; class Test { public static 

Java Beginners

program code for this question - Java Beginners
: Write a Java application, ProduceBills.java, that reads the name of the file from the keyboard, and generate a monthly bill for each customer in the file. Program should send each customer?s bill to a text file whose name is the customers?s 

Programming Tutorials

How to make a zip file in java
Description: In this example we will discuss about how to create zip file from the text file. In the following code  ZipOutputStream class from... zip file. Code: import java.io.*; import java.util.zip. 

Java Beginners

can u plz try this program - Java Beginners
. And the important thing is, total file should not be re-written for every add/delete... application for a school. Tasks will be Add Record, Edit Record, Delete Record, List... Display Record From Database Id 

Programming Tutorials

JDOM Element Example, How to remove child of an element from xml file in java.
JDOM Element Example, How to remove child of an element from xml file in java. In this tutorial, we will see how to remove child of an element from xml file... for manipulating, creating and serializing  xml file. With the help of this java 

Java Server Faces Questions

Problem to print from my properties file - Java Server Faces Questions
Problem to print from my properties file  Hi, I am a new user of this site. It is very interesting. So this is my problem: I have a jsp file where i try to print some messages from my properties file but when i execute 

Java Beginners

download a file from browser - Java Beginners
download a file from browser  How to download a file from browser and save it in local path 

Java Beginners

java compilation error - Java Beginners
in java graphics to be able to save it as a file if so, how can I do...java compilation error  Hello, I sent a previous message regarding... the codes I still received this message. My program compiles with no errors but I just 

Java Server Faces Questions

Problem to print from my properties file - Java Server Faces Questions
Problem to print from my properties file  Hi, I am a new user of this site. It is very interesting. So this is my problem: I have a jsp file where i try to print some messages from my properties file but when i execute 

JSP Servlet Questions

Generated java file - JSP-Servlet
in the generated java file Syntax error on token ";", delete this token...Generated java file  Hello friends, At run time JSP files will be translated as JAVA SERVLET files. I got this error at run time 

Java Beginners

Reading text from image file - Java Beginners
Reading text from image file  How Read text from image file 

Java Beginners

error while running the applet - Java Beginners
: 1. Save your file from MyFrame.java. 2. compile it from javac MyFrame.java...error while running the applet  import java.applet.Applet; import...); ++num; } } } } i have problem while running the code , error 

Java Beginners

File copy through intranet - Java Beginners
File copy through intranet  Can i copy files from system A to System B connected through intranet?? Is this possible through java IO? If yes, please let me know 

Struts Questions

Struts File Upload Example - Struts
Struts File Upload Example  hi, when i tried the struts file upload example(Author is Deepak) from the following URL http://www.roseindia.net... with size>1 MB , getting error "file size is large". if i want to upload 

Java Beginners

java program
java program  Write a Java application to print your name, ID, gender, and nationality.. the output will look like this : my id is 0123456789 i am a man i am from thailand 

JSP Servlet Questions

delete a file - JSP-Servlet
delete a file  Correct question::::How can we delete a file which is stored in a server when read write operations for this particular file is closed.  http://www.communigate.com/CommuniGatePro/WebFiles.html 

JSP Servlet Questions

java compilation error - JSP-Servlet
java compilation error  How to compile a java Program,If i am having jdk1.5 in webligic it support jdk1.4..When i put a .class file into WEB-INF/classes/Mybeans/Datacon.class it was given a error  Hi friend 

JSP Servlet Questions

delete a file - JSP-Servlet
delete a file  How can we read a file which is stored in a server when read write operations for this particular file is closed 

JSP Tutorials

Send Email From JSP & Servlet
J2EE Tutorial - Send Email From JSP & Servlet... mail from... data such as 'from', 'to', 'subject' and 'message 

PHP Tutorial

First Program
the name of my computer, the directory in which the PHP file is saved and the file name. See, it is like: http://Deepak/sample/roseindia.php 3.3 Error Messages If you are opening the file from the exact route, the file will be opened 

Development process Questions

Reading duplicate keys from .properties file - Development process
Reading duplicate keys from .properties file  Hi, I am reading a .properties file using a basic java program.Though the .properties file will not allow duplicate keys, but still I want to develope a program to identify 

XML Questions

parsing XML file to get java object - XML
parsing XML file to get java object  Hello, I'm facing a problem in parsing XML file to get the java object. I've tried to retrieve data from XML file using SAX parser. my XML file structure is the following 

Java Beginners

File - Java Beginners
. Here it is: Write a program to create a file named "numbers.dat". Then create... number integers from 1 to 100, separated by a comma to the end of the file. Reopen the file, and display the results. Write all even numbered integers from

General

Accessing Database from servlets through JDBC!
. Unzip the downloaded file into your favorite directory... emaildb.java file, move emaildb.class file to Java Web Servers.... For example, we can use the following code to connect our program to MySQL 

PHP Tutorial

php array delete element
removes the element starting from given index with the given length. Length is optional.If not given all elements get removed PHP Array Delete Element Example <?php     $ar1=array("aaa","bbb","ccc","ddd","eee 

Java Beginners

error in program when trying to load image in java - Java Beginners
error in program when trying to load image in java  Hi, I'm trying to add an image to my GUI using java graphics. I have cleaned up all my compiler errors but my program still won't run. I keep getting this type of message and I 

Java Beginners

File Writing - Java Beginners
File Writing  Hi... I need a syntax or logic or program by which we can write into the desired shell of the Excel file from console window...  Hi friend, I am sending you a link. This is will help you. Please 

Java Beginners

Java Calculator program - Java Beginners
the above program gives 15 but I would like to see 17 and the subtract 2 from...://www.roseindia.net/java/example/java/swing/calculator-in-swing.shtml Hope...Java Calculator program  import java.awt.*; import javax.swing. 

Development process Questions

Java Compilation error - Development process
product ODBC,,,i want directly to upload a .xls file intlo remote database in java...Java Compilation error  hi my serious problem is,how can i upload a file directly to the current remote database.. Below steps might work. 1 

Java Beginners

how to call an exe file from java - Java Beginners
how to call an exe file from java  hi, how to call exe file with some parameters from java and save the output of the exe file in a specified path. Please let me know immediately..its urgent!!! Thanks in advance 

General

Convert text file to XML file in Java
Convert text file to XML file Java In this section, you will learn how to convert the text file into xml file in Java language. To do this, we have used... that Transformer class process XML from a variety of sources and write 

Java Beginners

Java Error - Java Beginners
Java Error  E:\SUSHANT\Core Java\FileHandling\Error>javac... ch= reader.read(); ^ 1 error import java.io.*; //program 9 class demo1 { public static void main(String args 

Java Beginners

java program - Java Beginners
Java programing environment   From where i can download the Java programming environment 

JavaMail Questions

when sending the mail from java I am getting the below error - JavaMail
when sending the mail from java I am getting the below error   when sending the mail from java I am getting the below error : Exception... not found in gnu.gcj.runtime.SystemClassLoader{urls=[file:/mail/mail.jar,file 

Java Beginners

java program - Java Beginners
java program  1.write a program to show traffic signal using multithreading. 2.Except an integer from 1-12 and display corresponding month. if the integer is not between 1-12 then give the errer message and promit 

Java Beginners

program code for this question - Java Beginners
, are kept in a file. Your task: Write a Java application LookUp.java that acts... file. The program should display the IP address together with all the associated... phrase and the entries in the file the program should display the search phrase 

Advertisements Advertisements
 

 

 

DMCA.com