My situation is as following : I have package packA where I have classA, and I have a file.txt in packB.resources. In classA I’m using this to access file.txt :
InputStreamReader in = new InputStreamReader(new FileInputStream("/packB/resources/file.txt"), "UTF-8");
But unfortunately it shows me an exception :
java.io.FileNotFoundException : \packB\resources\file.txt (The
specified path was not found)
The FileInputStream class opens a file in the file system based on a file system path.
But what you are apparently trying to do is to open a resource located via the classpath. You should be using
Class.getResourceAsStream(String).