Exception in thread “main” java.nio.file.InvalidPathException: Illegal char <:> at index 2:

前端 未结 4 1015
礼貌的吻别
礼貌的吻别 2020-12-15 16:57

I have to copy classpath resource from one package to another.

My program is:

    public static void main(String[] args) throws IOException, URISynta         


        
4条回答
  •  一生所求
    2020-12-15 18:01

    problem is that Paths.get() doesnt expect that kind of value which is generated from uri.getPath().

    Solution:

    URI uri = ClassLoader.getSystemResource("com/stackoverflow/json").toURI();
    String mainPath = Paths.get(uri).toString();
    Path path = Paths.get(mainPath ,"Movie.class");
    

提交回复
热议问题