Hey zusammen,
habe ein kleines Problem beim beziehen von Files aus einem Package.
Der untenstehende Code funktioniert in Netbeans, sobald ich ein Jar daraus baue kommt nichtsmehr zurück ...
Woran liegt das und wie kann ich das beheben?
Danke!
habe ein kleines Problem beim beziehen von Files aus einem Package.
Der untenstehende Code funktioniert in Netbeans, sobald ich ein Jar daraus baue kommt nichtsmehr zurück ...
Woran liegt das und wie kann ich das beheben?
Danke!
Code:
public static String[] getRessources(String pack) {
String content = "";
pack = correctRessourcesPath(pack);
try {
Class resourceClass = Client.class;
InputStream fileStream = resourceClass.getResourceAsStream(pack);
for (int c = fileStream.read(); c != -1; c = fileStream.read()) {
content += (char) c;
}
} catch (Exception e) {
e.printStackTrace();
}
String[] ressources = content.split("\\n");
for (int i = 0; i < ressources.length; i++) {
ressources[i] = pack + ressources[i];
}
return ressources;
}
private static String correctRessourcesPath(String path) {
path = path.replace(".", "/");
if (!path.startsWith("/")) {
path = "/" + path;
}
if (!path.endsWith("/")) {
path += "/";
}
return path;
}