Package com.zyf.day22;
Import Java.io.File;
Import Java.io.FileInputStream;
Import Java.io.FileOutputStream;
Import java.io.IOException;
Import java.util.Properties; Requirements: Use properties to achieve the software can only run three times, more than three times after the prompt to purchase genuine, back JVM public class Demo5 {public static void main (string[] args) throws IO
Exception {File File = new file ("C:\\count.properties");
if (!file.exists ()) {file.createnewfile ();
//Create Properties Object properties = new properties ();
Load the information of the configuration file into the properties Properties.load (new FileInputStream (file)); int count = 0;
Defines the number of times that the variable is used to save the running times of the software. String value = Properties.getproperty ("Count");
if (value!=null) {count = Integer.parseint (value);
//Judge if the number of times used has reached three if (count = 3) {System.out.println ("You have used the software has been used three times, please purchase genuine software");
System.exit (0);
} count++;
SYSTEM.OUT.PRINTLN ("You have used the software" + Count + "Times");
Properties.setproperty ("Count", Count + "");
Use properties to generate a configuration file Properties.store (new FileOutputStream (file), "Runtime"); }
}