Results 1 to 6 of 6

Thread: File.delete() not working [RESOLVED]

Threaded View

  1. #1

    Thread Starter
    Hyperactive Member rockies1's Avatar
    Join Date
    Jul 1999
    Location
    Stuck at work
    Posts
    375

    File.delete() not working [RESOLVED]

    I have the following Java code for FTPing files. When the file errors out (happens if there is no source file to pull) I get a zero-byte file in the destination. I want to kill that zero-byte file, but this code does not do it.

    Any ideas?
    Code:
    	public void doFTPGet() throws Exception
    	{
    		FtpClient fcMyFtp = new FtpClient();
    		fcMyFtp.openServer(this.getHOST());
    		fcMyFtp.login(this.getUID(), this.getPW());
    		
    //		reading a file:
    		if(this.IS_BINARY)
    		{
    			System.out.println("Getting Binary");
    			fcMyFtp.binary();	
    		}
    		else
    		{
    			System.out.println("Getting ASCII");
    			fcMyFtp.ascii();
    		}
    		try
    		{	
    			byte buffer[] = new byte[1000];
    			int len;
    	 		FileOutputStream fos = new
    	 		FileOutputStream( this.getLOCAL_FILE() );
    	 		TelnetInputStream   tis =	 fcMyFtp.get(this.getREMOTE_FILE());
    	 		while( (len = tis.read(buffer)) != -1 ) 
    	 		{
    		 		fos.write(buffer,0,len);
    		 		//System.out.println("Reading");
    	 		}
    	 		tis.close();
    	 		fos.close();
    	 	}
    	 	catch( IOException e ) 
    	 	{
    	 		e.printStackTrace();
    			//Delete the file
    			File filepath = new File(this.getLOCAL_FILE());
    			filepath.delete();
    			throw new Exception(e.toString());
    	 	}
    
    	 	System.out.println("Done!");
    	 }//End doFTPGet
    Also, my file to delete is fully qualified with the path & filename...
    Last edited by rockies1; Mar 17th, 2004 at 10:13 AM.
    Morgan
    [email protected] - Home
    [email protected] - Work
    Using VB6 SP6 but trying to learn VB2005EE

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width