I have project with name 'XMLparser
'. In project have one folder with name 'XML
' which contains the file 'database.xml
' When I try to get directory to database Java show error.
Java error:
Exception in thread "main" java.lang.IllegalArgumentException: InputStream cannot be null
at javax.xml.parsers.DocumentBuilder.parse(Unknown Source)
at XMLparser.main(XMLparser.java:24)
I try to get directory with this code:
Document document = builder.parse(ClassLoader.getSystemResourceAsStream("../xml/database.xml"));
Project tree:
XMLparser
src
- (default package)
- XMLparser.java (My code is here)
JRE System Library
xml
- database.xml (This is the xml file)
What need to type here ClassLoader.getSystemResourceAsStream("HERE
") to work?