deleting file doesn't work - strange filename

hi people!

Currently i am writting an application which reads spam mail's from a folder (*.eml) and then moves these files to another directory.

first problem was that the filenames were too long/have stange characters,

so the file.renameTo(); methode didn't work.

example: nhw81@korea.com_y5fzqobl70ax4sxbaz8x@loewy.at-_ 5__ _=_ _!_img src=_hfoh2of2g42gg42.gif_ onerror=_top.document.location='httpdae.%7a%69%6f%6c%6f.%62%65'523D7388.eml

solution: i copyed the files by using the Stream classes. (FileInputStream/FileOutputStream)

at last step i need to delete the file in the source dir.

file.delete() works just somtimes fine.

any ideas?

- convex

[714 byte] By [Convexa] at [2007-9-25]
# 1
I suspect if the rename fails the delete will fail too.
ejpa at 2007-7-14 > top of java,Core,Core APIs...
# 2
right, each of the methodes works fine on some files. (short name, no invalid char, ...)but most of the files have long names - and so the two methodes don't work.
Convexa at 2007-7-14 > top of java,Core,Core APIs...
# 3
Strange that you can even open the files if you can't rename or delete them.Whoever is creating those names will have to do better.
ejpa at 2007-7-14 > top of java,Core,Core APIs...
# 4
these files were created by a spam software.--> no chance to change that.is there a way to delete files, without using the delete() methode ?
Convexa at 2007-7-14 > top of java,Core,Core APIs...
# 5
It will be platform dependent, but if you have a reliable UNIX rm or Windows del command that you can reliably run from a command prompt, then you could use Runtime exec method call to invoke the command you know works.
JohnKeltya at 2007-7-14 > top of java,Core,Core APIs...