Home arrow static arrow Java Programming [Archive] - about delete file
Warning: Creating default object from empty value in /www/htdocs/w008deb8/wiki/components/com_staticxt/staticxt.php on line 51
Java Programming [Archive] - about delete file
This topic has 2 replies on 1 page.

Registered: 4/8/04
about delete file  
Jun 18, 2004 9:33 PM

a file has password in it,when I delete the file,first I use objInput.readObject() and get the password;
then compare the inputed password by user; but when password is correct,delete the file is not able;
this file is using;the upon objInput.readObject() let this file is using;

this problem how to solve?

Registered: 8/15/02
Re: about delete file  
Jun 18, 2004 9:38 PM (reply 1 of 2)

Assuming you are using ObjectInputStream, make sure you close the file before deleting it.

Registered: 00-08-28
Re: about delete file  
Jun 18, 2004 9:59 PM (reply 2 of 2)

closepublic void close()           throws IOExceptionCloses the input stream. Must be called to release any resources associated with the stream.  Specified by:close in interface ObjectInputOverrides:close in class InputStreamThrows: IOException - If an I/O error has occurred.    Sample code for Reading a File   public void inputFile(String fileName)  throws IOException,ClassNotFoundException     {        File inFile = new File(fileName);   //Instantiate File Class        FileInputStream inStream = new FileInputStream(inFile); // FileInputStream      	 ObjectInputStream itemsIn = new ObjectInputStream(inStream); //ObjectInputStream		       	// Assign the properties to the instance of the Object      	 this.numItems = itemsIn.readInt(); // Read numItems property and assign to       	 this.inventory = (Item []) itemsIn.readObject(); // Read Items into array - notice the casting      	          	 itemsIn.close();  //close File      }//End readFromfile 
This topic has 2 replies on 1 page.