は、次のコードの問題が修正されましたが、私は、データベース接続文字列を含むファイルを設定へできるようにしたい誰かが私の宿題のjarと同じレベルのjava参照ファイルを手伝ってくれますか?ない最も優雅な方法 - -
package six.desktop.gui.common;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;
public class Config
{
private static final String configFileName = "/config/config.ini";
private Config()
{
}
public static String getPropertyValue(String propertyName) throws IOException
{
URL url = new Config().getClass().getResource(configFileName);
BufferedReader br = new BufferedReader(new InputStreamReader(url.openStream()));
String inputline = "";
while ((inputline = br.readLine()) != null)
{
if (inputline.contains(propertyName))
{
int index = inputline.indexOf(propertyName);
index += propertyName.length() + 1;
return inputline.substring(index, inputline.length());
}
}
return null;
}
}
この割り当てのための迅速な解決を必要としますは、ジャーと同じレベルに位置すること。どうすればこれを達成できますか?または私が欲しいものとは異なるアプローチがありますか?
私は、現時点ではちょうどにハードコードの接続を持っているDBハンドラクラスを持っている。
ダウンリスト:あなたが同意しない理由を説明するコメントを残してください。 –