Unable to write to the configuration file using Properties, solve the

< H2 > NewFile.java < / H2 >
private File configurationFile;

public NewFile(File file){
    this.configurationFile = file; 
}

public void newFile() throws IOException{
     if (!configurationFile.exists())
         configurationFile.createNewFile();
    
}
< H2 > Configuration.java < / H2 >
private File configurationFile;
private Properties pro;
private FileInputStream input;
private FileOutputStream  output;
int count = 0;

public Configuration(File configurationFile, Properties pro, FileInputStream input, FileOutputStream output){
    this.configurationFile = configurationFile;
    this.pro = pro;
    this.input = input;
    this.output = output;
}

public void write() throws IOException{
    pro.load(input);
    
    String value = pro.getProperty("name");
    if (value != null){
        count = Integer.parseInt(value);
    }
    countPP;
    
    pro.setProperty("name", count + "");
    pro.store(output, "");
    
    input.close();
    output.close();
}
< H2 > Main.java < / H2 >
public static void main(String[] args){
    Configuration config = null;
    File configFile = null;
    FileInputStream input = null;
    FileOutputStream output = null;
    Properties pro = null;
    NewFile newFile = null;
    
    try{
        configFile = new File("info.ini");
        newFile = new NewFile(configFile);
        newFile.newFile();
        input = new FileInputStream(configFile);
        output = new FileOutputStream(configFile);
        pro = new Properties();
        config = new Configuration(configFile, pro, input, output);
        config.write();    
    }catch(IOException e){
        e.printStackTrace();
    }finally{
        if(input != null){
            try{
                input.close();
            }catch(IOException e){
                e.printStackTrace();
            }
        }
        if (output != null){
            try{
                output.close();
            }catch(IOException e){
                e.printStackTrace();
            }
        }
    }
}

I tested the code and found

if (value != null){
        count = Integer.parseInt(value);
    }

did not execute, but do not know why, solve

Mar.11,2021

try changing the configuration file suffix to properties


just created an empty file info.ini,

String value = pro.getProperty("name");//valuenullif
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b302c3-2b53e.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b302c3-2b53e.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?