Count Number of times the program has been executed

How can I get the number of times the program was previously executed in java without saving the file and scoring. Is there an application class or something in java to check for count

+5
source share
2 answers

You can use the settings API . This eliminates the need for I / O files. You still need to read the preference value, increase it, and then save the new value.

The Windows Preferences API uses the registry. On Unix, the preference API uses the file system as the backup storage (but this is hidden from you as a developer).

/ , . ( , , , ). Preferences.systemNodeForPackage() Preferences.userNodeForPackage() .

+6

- :

public class Test {

    private static int INSTANCE_COUNTER = 0;

    public Test() {

        INSTANCE_COUNTER++;
    }

    public static final int getInstanceCounter() {

        return INSTANCE_COUNTER;
    }

    //-Methods-//
}

Test.getInstanceCounter(), .

0

All Articles