• Post Reply Bookmark Topic Watch Topic
  • New Topic

Delete String from Text File fails on deployment.  RSS feed

 
S Shiva
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys....
This is the code that i have used to delete particular String from text file. It works absolutely fine on eclipse and netbeans.. But on deployment(in tomcat) it fails to delete message/rename or delete original file even though all permissions for modifying the files in the folder has been given to all users.
Please help solve my problem.
This is my code:


Thank You.
 
K. Tsang
Bartender
Posts: 3648
16
Firefox Browser Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What OS are you deploying on, Windows or Unix/Linux?

Without going through your code thoroughly, you are using a windows path D:\\...

Besides that, what does the Tomcat log say?
 
S Shiva
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Its on Windows Server 2003. I have deployed in Tomcat 6.0 and 7.47.
There is nothing in Tomcat logs.. not even sysout statements, even though I am able to add String to the text file. So I know folder or file rights is not an issue.
Just not able to delete String.
This is the code for appending string to file.
 
Paul Clapham
Sheriff
Posts: 22835
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
S Shiva wrote:There is nothing in Tomcat logs.. not even sysout statements


Then either you aren't running that code at all, or else you are looking in the wrong place for the logs.
 
S Shiva
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@Paul: You were right.. I was looking at the wrong Tomcat folder..

This is the log generated when removeLine method is executed:


When I try to manually delete the text file it gives "Cannot delete Copy of Scroll : It is being used by another person or program. Close any programs that might be using the file and try again."'
Is it because I am deploying it in webapps folder of Tomcat and file generated is in some other drive(I think not but still asking..).
 
Paul Clapham
Sheriff
Posts: 22835
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As far as I can tell your code first reads from that file, then it fails to close that file, then it tries to write to that file. That's why the error occurs. That's also why you get a message which says the file is still open by another application -- because your application didn't close it.
 
S Shiva
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But I am closing the reader and writer before attempting to delete/rename the file...

lines 58,59,60 of removeLine.java
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!