Link to home
Start Free TrialLog in
Avatar of Wilson Net
Wilson NetFlag for Argentina

asked on

URL.getPath return wrong file path in linux

I have a Web App in Java running in ubuntu 18.04 and I need to make a URL to the wildfly path to use in a custom file writter.

I use the following code to create the URL object

URL rutaWildfly = new URL("file://opt/wildfly/standalone/deployment/temp.locale");

Open in new window


but when i use that object show me a File not found error, and when i do

System.out.println(rutaWildfly.getPath());

Open in new window


it show: /wildfly/standalone/deployment/temp.locale

why the URL object is removen the /opt/ from the path?

this only happen in linux, if i change the file path to windows it work fine.
ASKER CERTIFIED SOLUTION
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Wilson Net

ASKER

when I added a third bar to file (file:///), I could get the correct path, thank you very much
:)