Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Linux Archive
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 08-07-2007, 05:05 AM
Member
 
Join Date: Jul 2007
Posts: 40
trill is on a distinguished road
Error: Cannot delete a.txt:It is being used by another person or program
Hi, My problem here is after I ran my code, I cant delete the origin file that I have ftp it. For example, I ftp C:\a\a.txt to /home/trill/upload/a.txt. After doing this, I need to delete C:\a\a.txt but I got this message "Cannot delete a.txt:It is being used by another person or program".
Anyone knows what wrong with my code here?

Code:
BufferedReader reader = null; Ftp ftp = null; String tmp = null; InetAddress Inet = null; try{ String lStrUploadFileLog = "C:/FTPLog/FTPLog_05122003.log"; String lStrUploadFilePath = "/home/trill/upload/"; String lStrFTP_USER = "trill"; String lStrFTP_PWD = "password"; String lStrFTP_IP = "192.168.1.100"; String lStrLogFileDate = "LOG_FILE_DATE"; reader = new BufferedReader(new FileReader(new File(lStrUploadFileLog))); Inet = InetAddress.getByName(lStrFTP_IP); tmp = reader.readLine(); ftp = new Ftp(Inet,lStrFTP_USER,lStrFTP_PWD); ftp.setType(ftp.BINARY); if(tmp != null){ System.out.println("lStrUploadFileLog = "+lStrUploadFileLog); System.out.println("lStrUploadFilePath+lStrLogFileDate = "+(lStrUploadFilePath+lStrLogFileDate)); ftp.startPut(lStrUploadFileLog,lStrUploadFilePath+lStrLogFileDate); System.out.println("tmp = "+tmp); StringTokenizer strtmp = new StringTokenizer(tmp,","); int size_strtmp = strtmp.countTokens(); while (size_strtmp>0){ String lStrUploadFile = strtmp.nextToken(); size_strtmp--; StringTokenizer strlStrUploadFile = new StringTokenizer(lStrUploadFile,"\\"); int size_strlStrUploadFile = strlStrUploadFile.countTokens(); String substr = lStrUploadFile.substring(lStrUploadFile.lastIndexOf("\\")+1,lStrUploadFile.length()); ftp.startPut(lStrUploadFile,lStrUploadFilePath+substr); ftp.waitUntilTransferComplete(); System.out.println("File(s) download completed!"); } try { File ff = new File(lStrUploadFileLog); System.out.println(ff.getAbsolutePath()); boolean state = ff.delete(); System.out.println(state); } catch ( SecurityException se ) { System.out.println("Error SecurityException: "+se ); se.printStackTrace(); } catch(Exception e){ System.out.println("Error Exception1: "+e ); e.printStackTrace(); } } System.out.println("Upload to server completed!!!"); }catch(Exception e){ System.out.println("Error Exception: "+e); } finally{ if(reader != null) reader.close(); if(ftp != null) ftp.close(); reader = null; ftp = null; tmp = null; Inet = null; }
Thanks.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 08-07-2007, 09:34 AM
Member
 
Join Date: Jul 2007
Posts: 40
toby is on a distinguished road
Its simple. start up in safe mode and simply delete the file. if that doesn't work try opening NOTEPAD and saving blank as same type of file you are trying to delete. hope this works for you.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Error: cannot resolve symbol' on Person (java.lang.String, java.lang.String) baltimore New To Java 2 09-18-2008 09:30 AM
CRC check program 1 error javakid9000 New To Java 1 03-19-2008 07:04 AM
Error :Invalid path, C:\Program Files\Java\j2re1.4.2_06\bin\javac.exe silvia New To Java 2 07-30-2007 10:55 AM
Error: Could Not Find Main Class. Program Will Exit silvia New To Java 1 07-19-2007 06:58 PM
How to delete a file Alpha New To Java 1 05-26-2007 10:11 AM


All times are GMT +3. The time now is 10:52 PM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org