We have existing files with "&" in file names and want to use java.io.File
,
for instance the method list()
. In this case, list doesn't return the directory entries. Escaping "&" with "\&" doesn't help. Thank you.
Asked
Active
Viewed 125 times
0

Julia
- 318
- 1
- 5
- 14
-
http://stackoverflow.com/questions/893977/java-how-to-find-out-whether-a-file-name-is-valid – Kai Sternad Dec 25 '11 at 23:48
-
Please list a small but runnable code snippet showing the behaviour you describe. – Thorbjørn Ravn Andersen Dec 26 '11 at 09:01
1 Answers
3
It works fine for me on Mac OSX. Please post your code illustrating the problem.
$ touch a\&b
$ touch c\ \&b
$ ls
a&b c &b
$ scala
scala> import java.io.File
import java.io.File
scala> new File(".").list()
res0: Array[java.lang.String] = Array(a&b, c &b)

I82Much
- 26,901
- 13
- 88
- 119