Hallo,
ich hab folgenden Code
Aber jedesmal wenn ich mir den Namen über getName() holen möchte ist dieser null. Kann jemand weiter helfen?
ich hab folgenden Code
Java:
ublic class Properties implements Serializable{
private static final long serialVersionUID = 895L;
private static Properties properties;
private String path = "../fx_Prop/properties.ser";
private String name;
private Properties() {
}
public static Properties getInstance(){
if(properties == null)
properties = new Properties();
return properties;
}
public void setName(String name){
this.name = name;
}
public String getName(){
return this.name;
}
public void LoadProperties(){
try
{
FileInputStream fileIn = new FileInputStream(this.getClass().getResource(path).toURI().getPath().toString());
if(fileIn.available() > 0){
ObjectInputStream in = new ObjectInputStream(fileIn);
properties = (Properties) in.readObject();
in.close();
fileIn.close();
}
}catch(IOException i){
i.printStackTrace();
return;
}catch(ClassNotFoundException c){
c.printStackTrace();
return;
} catch (URISyntaxException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
private Object readResolve() throws ObjectStreamException {
return getInstance();
}
public void SaveProperties(){
try
{
FileOutputStream fileOut = new FileOutputStream(this.getClass().getResource(path).toURI().getPath().toString());
ObjectOutputStream out = new ObjectOutputStream(fileOut);
out.writeObject(properties);
out.close();
fileOut.close();
}catch(IOException | URISyntaxException i)
{
i.printStackTrace();
}
}
public int hasCode() {
return 810;
}
}
Aber jedesmal wenn ich mir den Namen über getName() holen möchte ist dieser null. Kann jemand weiter helfen?