Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Simple Java Singelton Example
package utils;
public class Enduro {
private static Enduro ourInstance = new Enduro();
public static Enduro getInstance() {
return ourInstance;
private Enduro() {
* Get path relative to root.
* @param relativePath the relative path to get (Starting at src/test/resources).
* @return the absolute path to resource.
public String getResourcePath(String relativePath) {
URL resourceUrl = Enduro.getInstance().getClass().getResource("../");
return resourceUrl.getPath() + relativePath;
Enduro enduro = Enduro.getInstance();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.