开发者

Get the original file name in java?

In Windows os, I have a file, for example "README" .

Using java, File("readme").exists() will return true

How to get the true file name, something like this:

  new File("r开发者_StackOverfloweadme").getTrueFileName()  //return "README"


Look at File.getCanonicalPath - that returns the "real" filename.

There's also File.getCanonicalFile which returns the same information but as a File object.

(I've just tested this with your exact situation, and it works fine.)


You could try File.getCanonicalPath. I don't have a Windows box to test this on, so it's just a stab in the dark.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜