Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Java by (3.9k points)
I have a unit test that needs to work with XML file located in src/test/resources/abc.xml. What is the easiest way just to get the content of the file into String?

1 Answer

0 votes
by (46k points)

Right to the point :

ClassLoader classLoader = getClass().getClassLoader();

File file = new File(classLoader.getResource("file/test.xml").getFile());

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

Browse Categories

...