java.io.FileNotFoundException on an existing file

后端 未结 5 1556
离开以前
离开以前 2021-02-15 17:47

I am getting this error when I try to open a file:

java.io.FileNotFoundException: D:\\Portable%20Programs\\Android%20Development\\workspace3\\XXX-desktop\\bin\\W         


        
5条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-02-15 18:07

    The confirmed solution is quite old and even though it works for this particular case it is far more convenient to use URLDecoder, because %20 is only one encoded character, but in your path there can be whole lot of different encoded characters.

    fileLocation = URLDecoder.decode(Main.class.getProtectionDomain().getCodeSource().getLocation().getPath(), "UTF-8");
    

提交回复
热议问题