0 votes
1 view
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 (46.1k points)

Right to the point :

ClassLoader classLoader = getClass().getClassLoader();

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

Related questions

Welcome to Intellipaat Community. Get your technical queries answered by top developers !