title: sparkjava: Load PNG as base64 from InputStream
body: <p>I have the following method to load resources as String where <code>path</code> is the String to the resource on my classpath (which works just fine on plain text):</p>
  
  <pre><code>try (Scanner scanner = new Scanner(MyClass.class.getResourceAsStream(path))) {
          return scanner.useDelimiter("\\A").hasNext() ? scanner.next() : "";
  }
  </code></pre>
  
  <p>Now I want to load a PNG image as a base64 String so I  can send it back through sparkjava with <code>Content-Type: image/png</code>.</p>
  
  <p>How can I do that?</p>
  
  <p><strong>Do not use any libraries, only plain old Java.</strong></p>