How to avoid auto forward slash IntelliJ IDEA 2022.2.1 in Windows 10

108 Views Asked by At

I am using IntelliJ IDEA 2022.2.1 editor. In one of my test case I am reading the file from resource folder using below method getClass().getResource(filename)

I can get the path, but problem is it's always returning with extra forward slash('/') for an instance /C:/Users/test/IdeaProjects/data.json like this.

Due to that extra slash at 0 index. I am getting java.nio.file.InvalidPathException.

Note: this works fine in mac book, This issue is only with window OS.

Any suggestion would be reuired.

0

There are 0 best solutions below