Vaadin 13 and VaadinService.getCurrent().getBaseDirectory()

What alternative is there to what was previously done with VaadinService.getCurrent().getBaseDirectory().getAbsolutePath()?

Hi Miguel,

based on https://vaadin.com/forum/thread/17283562/how-to-get-the-absolute-path-in-vaadin-10, this is the solution I’m currently using:

public static String getBaseDirectory() {
	ServletContext currentServletContext = VaadinServlet.getCurrent().getServletContext();
	//
	String realPath = AServletContext.getResourcePath(currentServletContext, "/");
	//
	return realPath;
}

protected static String getResourcePath(ServletContext currentServletContext, String path) {
	String resultPath = currentServletContext.getRealPath(path);
	//
	if (null != resultPath) {
		return resultPath;
	}
	else {
		try {
			resultPath = currentServletContext.getResource(path).getFile();
		} catch (Exception exception) {
		}
	}
	//
	return resultPath;
}

Hope it helps,
MZ