Java – how does OS X recognize a drive letter?

I Know. Heresy But I'm in trouble I have many configuration files that use absolute pathnames, which will cause incompatibility between OS X and windows If I can identify OS X (which I think is more flexible) as Q: / foo / bar / BIM Properties as a valid absolute file name, then it will save me working days tracking and configuration files through the stack

Finally, I need this java test code to print "success!" When it runs:

import java.io.*;

class DriveLetterTest {
    static public void main(String... args) {
        File f = new File("S:");
        if (f.isDirectory()) {
            System.out.println("SUCCESS!");
        } else {
            System.out.println("FAIL!");
        }
    }
}

Anyone knows how to do this?

Update: thanks for everyone's feedback Now it's obvious to me that my problem should be clearer

The configuration files and the code that uses them belong to third-party packages that I cannot change (well, I can change them, but this means that there will be a continuous maintenance load. If possible, I want to avoid this burden.)

I fully agree with all those who are shocked by this situation But the fact remains: I can't change third-party code. I really want to avoid allocating configuration files

Solution

Probably you have to provide a different Java io. File implementation, which can correctly parse the file path. Maybe someone has made one The real solution is to put this kind of thing (hard coded file path) in the configuration file instead of the source code

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>