I wanted to remove the spaces that Windows puts in filenames. I ran the following code to rename all the files in a test directory thus. The result: all the files disappeared. I am puzzled as to why.
import java.io.*; public class FileRenamer { public static void main(String[] args) { for (File file: (new File("O:\\test0")).listFiles()) file.renameTo(new File(file.getName().replaceAll("\\s",""))); System.exit(0); } }