Reputation: 2586
I am making a simple MP3 player and have imported mp3 files from a certain directory. I want to change the path to have double backslashes, however it's not registering.
matchingFiles = dir.listFiles(textFilter);
for(int i = 0; i<matchingFiles.length; i++){
String s = matchingFiles[i].toString();
String t = s.replace("\\", "\\\\");
matchingFiles[i] = new File(t);
System.out.println(matchingFiles[i]);
fileList.add(matchingFiles[i]);
}
The print gives single backslashes, while t has double. File.renameTo() didn't seem to work either, so I'm wondering how to change the path in an existing File.
Upvotes: 1
Views: 81
Reputation: 22873
The File
class aims at representing system paths in its own way, well, the system way. In other words, File
understands paths as folders seperated by \
, not \\
. You can't change that. The question is, why would you?
Upvotes: 2