Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
ファイルが.jarあり、そのルートにフォルダーがあります。FileこのフォルダをJavaクラスに読み込むにはどうすればよいですか?
.jar
File
このファイルはファイル システム上に独立して存在しないため、File は使用できません。代わりに、次のように、フォルダーの内容を取得するために getResourceAsStream() が必要です。
InputStream in = getClass().getResourceAsStream("/FILENAME.TXT"); BufferedReader input = new BufferedReader(new InputStreamReader(in));