If you want to read the file from the application, use the code below:
InputStream input = getClass().getResourceAsStream("/classpath/to/my/file");
The path begins with a "/", but it is not the path of the file system and represents a classpath. If the desired file exists in classpath "org.xml" and the file name is myxml.xml, the path will be like "/org/xml/myxml.xml".
InputStream is responsible for reading the contents of the file. You can also wrap it around a Reader object as needed.
I hope it helps.
916 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
620 Uncaught (inpromise) Error on Electron: An object could not be cloned
574 Who developed the "avformat-59.dll" that comes with FFmpeg?
613 GDB gets version error when attempting to debug with the Presense SDK (IDE)
© 2024 OneMinuteCode. All rights reserved.