Assuming your Status array is not empty, this code will work but the file text file will be updated in the compiled/output directory
So the text file in the source directory will not be updated, but the one in the output directory will.
Also note that the constructor of FileWirter you are using will overwrite the content of the file so you should use the one with the append argument:
public FileWriter(String fileName, boolean append) throws IOException
EDIT : if you REALLY need to update a file in the src directory you could do it like, this.
Not really nice but this will work
public void updateF()throws Exception
{
String fileName = "valS.txt";
File fileInClasses = new File(getClass().getResource(fileName).getFile());
System.out.println(fileInClasses.getCanonicalPath());
File f = fileInClasses;
boolean outDir = false;
// let's find the output directory
while(!outDir){
f = f.getParentFile();
outDir = f.getName().equals("out");
}
// get the parent one more time
f = f.getParentFile();
// from there you should find back your file
String totoPath = f.getPath()+"/src/com/brol/" + fileName;
File totoFile = new File(totoPath);
BufferedWriter outputWriter = null;
outputWriter = new BufferedWriter(new FileWriter(totoFile, true));
outputWriter.append("test");
outputWriter.flush();
outputWriter.close();
}
Status[]? Where is that populated?