Search code examples
javafileclassloader

have a file in the classloader's root path, how to create it


File f = new File(path)

How to give the path parameter in this case?


Solution

  • You mean something like this?

        URL resource = Thread.currentThread().getContextClassLoader().getResource("config.properties");
        File f = new File(resource.toURI());