I am using some API in which there is a class Reader which have a method readXml(String path)
now when i use this method and give some path which in my computer like
Reader reader = new Reader();
reader.readXml("C:\\work\\myfile.xml");
it always faile to read the file
In there API documentation it is mentioned
readXml(java.lang.String resourcePath)
Loads the orthography model, from the specified embedded JAR resource.
so do i need to put my file in some embedded jar resources ,if yes what would be the way of doing it and then reading from it
Thanks
The wording is a bit strange, but I think that what the documentation means is that the resource path is a path used by the classloader to load a resource. The file is thus not searched in the file system, but in the classpath, following the rules detailed in ClassLoader.getResource().
So, the XML file should be accessible from the classpath. Suppose
c:\workis in the classpath, the resource path should thus be"myfile.xml"or"/myfile.xml"depending on how this method is implemented. Ifc:\is in the classpath, then the path should be"work/myfile.xml"or"/work/myfile.xml".If this library is a general-purpose API and is well-designed, it should accept something other than a resource path as argument, like a java.io.Reader or java.io.InputStream.