Java Relative Path Issue -
I am facing a problem when trying to solve the file path using relative path in Java. I'm not sure where I have failed, can you get help from me? Thanks!
@Test Public Null Exempt Object (Nautical) Exceptions thrown {FileReader fileReader = New FileReader (GetClass (). GetResource ("./ JavaPractice / resources / tests / codeeval / fileReaderTest.txt" ) .Wire()); AssertNotNull (FileReader); } Exception:
java.lang.NullPointerException at components.com.codeeval.FileReader.FileReaderTest.testObjectNotNull (FileReaderTest.java13) on the sun. .NativeMethodAccessorImpl.invoke0 (native resident method) at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62) Directory structure:
JavaPractice
- resources.tests.codeeval.fileReaderTest.txt (the file that I am trying to access)
- test.components.com.codeeval.FileReader.FileReaderTest.java (that is Janet Trying to use the above file)
Money files are not. They are usually jar file entries. You should use a class or classloader's resource API to return an input stream to you.
Comments
Post a Comment