• Post Reply Bookmark Topic Watch Topic
  • New Topic

Can't Delete File with Process

 
Chris Baty
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm trying to delete image files from a virtual scrapbook. The user can upload file names with spaces, like "my pi.jpg" But when I try to delete them using a JAVA Process it keeps choking on the spaces.



Any ideas would be appreciated.

Thanks.
Chriis
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use one of the Runtime.exec variations that takes a String[] as parameter; those know how to deal with spaces.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Or use Apache Commons IO, which has a FileUtils class with several varieties of file deletion methods.
 
Chris Baty
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, this is what I did:


You saved me a butt load of time.

Chris
 
Rob Spoor
Sheriff
Posts: 20820
68
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why use a process to delete or move files? File.delete() and File.renameTo() should work just fine.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!