title: ClassLoader.getResource returns odd path (maybe)?
body: <p>When loading an asset such as a text file from the resources folder, the most common approach is to use ClassLoader to get the path:</p>
  
  <pre><code>String path = getClass().getClassLoader().getResource("file.txt").getPath();
  </code></pre>
  
  <p>You can then use any of the many readers that java has to read the content of that file. But for some reason, <code>Paths.get(path)</code> is not happy with the path:</p>
  
  <pre><code>byte[] content = Files.readAllBytes(Paths.get(path)) 
      -&gt; throws java.nio.file.InvalidPathException when executed
  </code></pre>
  
  <p>ClassLoader.getResource(...).getPath() is returning:</p>
  
  <pre><code>/D:/Projects/myapp/build/resources/main/file.txt
  </code></pre>
  
  <p><code>Paths.get()</code> doesn't like it. Apparently the ':' after <code>/D</code> is an 'Illegal char'. (Note that the path seems correct, the file is actually there)</p>
  
  <p>Which one is causing the problem? Is <code>ClassLoader.getResource()</code> returning an invalid path or is <code>Paths.get()</code> acting up over nothing?</p>
  
  <p><br>
  <em>Some time later</em><br>
  It seems that there are multiple different formats for paths in java. The various frameworks don't appear to completely agree on what is right and what is wrong, therefore there are various discrepancies between the paths that they create and accept.</p>
  
  <p>In this example, <code>Paths.get()</code> was in fact not expecting the leading slash in the path:</p>
  
  <pre><code>/D:/Projects/myapp/build/resources/main/vertex.vs.glsl &lt;- EVIL
  D:/Projects/myapp/build/resources/main/vertex.vs.glsl &lt;- OK
  </code></pre>
  
  <p>I suppose that the question now is: How do I sanitise file paths returned by <code>ClassLoader.getResource()</code> for use with <code>Paths.get()</code> properly? Are there any other differences between their two file path formats?</p>