Skip to content

Instantly share code, notes, and snippets.

@simonwoo
Created January 11, 2016 15:31
Show Gist options
  • Select an option

  • Save simonwoo/eb5ee5ce70444f0b7fba to your computer and use it in GitHub Desktop.

Select an option

Save simonwoo/eb5ee5ce70444f0b7fba to your computer and use it in GitHub Desktop.
private static byte[] loadImage() {
        URL url = Thread.currentThread().getContextClassLoader().getResource("photo.png");

        try {
            return Files.readAllBytes(Paths.get(url.toURI()));
        } catch (Exception e) {
            throw new RuntimeException("Can not load the image");
        }
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment