0

これはおそらく何人かの人からの繰り返しの質問ですが、答えを探しても理解できませんでした。

netbeansは、ビルド操作の後にフォルダdistを作成します。そのフォルダにテキストファイルを配置したいのですが、jarファイルはテキストファイルを読み取る必要があります。

ターゲットプラットフォームはWindowsとLinuxです

フォルダの構造、

.java file  =  C:\My Documents\NetBeansProjects\Example\src\example
 build folder = C:\My Documents\NetBeansProjects\Example
 build folder contains classes folder. classes folder contains all the class files
 dist folder = C:\My Documents\NetBeansProjects\Example
 dist folder contains the .jar files and i want to place a text file inside this folder

 getClass().getClassLoader().getResource("example.txt");

パスが.javaファイルと一緒にある場合にのみ機能するようです。

ありがとう

4

1 に答える 1