How to write to Preferences.txt
              in 
             Library and Tool Development 
              •  
              3 years ago    
            
 
           
             Hi, 
             
             
 
             
             
             
 
             
             
              
            
             
            
            
             
            
            
             
            
            
             
            
            
             
            
            
             
            
            
             
            
            
             
            
            
             
            
            
             
            
            
             
             
           
 
            
           
              Can anyone advise me on how to write new settings into Preferences.txt?  A Tool I'm working on needs to remember a variable from one launch to the next. 
            
 
            
              I've tried using the following code to append a line to the preferences file: 
            
 
            -  
File prefFile = Base.getSettingsFile( "Preferences.txt" );
PrintWriter prefWriter = null ;
try {
prefWriter = new PrintWriter( new FileWriter(prefFile, true ));
prefWriter.println( "newSetting = value" );
prefWriter.close();
} catch (IOException e) {
}
 
             This works temporarily.  When I view preferences.txt immediately after this code executes my new Setting shows up.  Once I close the Processing app, though, my new Setting is erased from the file.
            
            
             Am I doing something wrong?  Is there some other function I should be using to add to Settings? 
            
            
             Or am I taking the entirely wrong approach?
            
            
             Thanks in advance,
            
            
             D.
            
             
              
              1  
            
 
            