Usando o path desta maneira você indica que o arquivo está localizado na pasta principal do projeto, e não na pasta da classe, coloque o arquivo na pasta root do projeto que deve funcionar.
viniciusalvess
packagebr.com;importjava.io.File;importjava.io.FileInputStream;importjava.io.FileNotFoundException;importjava.io.FileOutputStream;importjava.io.IOException;importjava.net.URL;importjava.util.Properties;publicclassParametrosextendsProperties{privatestaticfinallongserialVersionUID=1L;privateFilefile=newFile("Parametros.properties");publicParametros(){super();if(!file.exists()){try{file.createNewFile();Propertiesdefaults=this.loadParametros();defaults.setProperty("nome","nomeDefault");defaults.setProperty("port","12345");defaults.setProperty("host","localhost");this.storeParametros(defaults);}catch(IOExceptione){// TODO Auto-generated catch blocke.printStackTrace();}}}publicParametros(Propertiesdefaults){super(defaults);}publicPropertiesloadParametros()throwsFileNotFoundException,IOException{Propertiesprops=newProperties();props.load(newFileInputStream(file));returnprops;}publicvoidstoreParametros(Propertiespropertie)throwsIOException{FileOutputStreamout=newFileOutputStream(file);propertie.store(out,null);out.close();}}
leoviniga
Opa…era um problema no path mesmo…a aplicação estava procurando o arquivo na pasta do eclipse (lol)…
eu substitui a linha por:
FileInputStream("C:/Documents and Settings/...")
o problema agora é achar uma maneira melhor de especificar o Path do arquivo…