• Post Reply Bookmark Topic Watch Topic
  • New Topic

Can using the same files in different methods cause problems?  RSS feed

 
Alice Hampton
Ranch Hand
Posts: 217
Chrome Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm reading from one file and writing it into another
I then want to delete the first file and use the second (it will get the first files name)
My sample java file works completely fine but it doesn't work on my actual file -it looks like it populates my test file like it should but it does not delete the original.
Occassionally DMap.xml won't delete either - I try and rename it and normally I get the error of 'the file is open in Java platform SE binary' so the files is open somewhere - but I thought I had closed it correctly so have I done that wrong?

I have put the basic code in to try and help support my explanation:
 
Darryl Burke
Bartender
Posts: 5167
11
Java Netbeans IDE Opera
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
http://www.java-forums.org/new-java/93323-can-using-same-files-different-methods-cause-problems.html
 
Alice Hampton
Ranch Hand
Posts: 217
Chrome Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Aw sorry! I forgot to post the opposite link here too So sorry!
 
Alice Hampton
Ranch Hand
Posts: 217
Chrome Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
*Edit* more in depth code


 
Knute Snortum
Sheriff
Posts: 4281
127
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My suggestion would be to take some time and build some working code that displays the problem. No Gui, just the file reads, writes, and renames. THe code you have posted is so full of errors that it's hard to know what to make of it.
 
Alice Hampton
Ranch Hand
Posts: 217
Chrome Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thats not my full code - I only have the one class but posting it all isn't the greatest idea I imagine also I can't remove the gui otherwise the project can no longer work - I need to use drop down menu's and such for selections. My code does all work fine atm just doesn't delete that file thats all
 
Knute Snortum
Sheriff
Posts: 4281
127
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Don't post the full code. Write a little program that just reads, writes, and renames. See is you get the same problem. If so, post the little program.
 
Dave Tolls
Ranch Foreman
Posts: 3067
37
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And that could be the problem, because the code you have shown involves taking an xml file, parsing it, writing it out and copying back onto the old file (I think).
This does not require a GUI at all, and should be easy enough to detach from your GUI code.

If it isn't, then you have probably intertwined your logic in far too tightly to your GUI.
Now might be a good time to take a step back and do some house cleaning.
 
Alice Hampton
Ranch Hand
Posts: 217
Chrome Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Good point - it actually wouldn't probably take much to remove the gui as the only reason it is used it for the comboBox. I have a sample file I could copy paste the code out of and place in there bit by bit as that one doesn't use a gui
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!