0

I have 2 questions about GWT:

I'm developing a app and it have to read a xml file that is inside project, but I put this:

Document doc = docBuilder.parse(new File(stringPath));

being stringPath:

URL path = nameClase.class.getProtectionDomain().getCodeSource().getLocation();
String stringPath = path.toString();
stringPath = stringPath.substring(5);
int num = stringPath.indexOf("classes");
stringPath = stringPath.substring(0, num + 8);
stringPath += "namePackage/nameFile.xml";

With this I get the route where It´s xml file. If I do this in my local machine is ok, but when I do a .war file only I select src folder and after with ant file I create my .war file, then when I deploy my gwt project in tomcat I don´t get do it ok, because the route that catch is:

machine/war/WEB-INF/classes/package/nameFile.xml

But when I do war file I don´t obtain the war/WEB-INF folder because I do a .jar the src folder.

How can I get the path to the xml file? This xml file is inside src folder.

The other question that I have is how do I create a log file? somebody have a example where I can see it?

Thanks.

Ltcs
  • 263
  • 1
  • 3
  • 15

1 Answers1

2

try

    InputStream is = getClass().getResourceAsStream("/namePackage/nameFile.xml");
    Document doc = docBuilder.parse(is);
Evgeniy Dorofeev
  • 133,369
  • 30
  • 199
  • 275