⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cryptixproperties.java

📁 jpeg2000编解码
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
    public static int getMinorVersion() { return MINOR_VERSION; }    /**     * Returns the intermediate version of this release of Cryptix.     */    public static int getIntermediateVersion() { return INTER_VERSION; }    /**     * Returns true iff this version of Cryptix is at least the given     * version.     */    public static boolean    isVersionAtLeast(int major, int minor, int intermediate) {        if (MAJOR_VERSION > major) return true;        if (MAJOR_VERSION < major) return false;        if (MINOR_VERSION > minor) return true;        if (MINOR_VERSION < minor) return false;        return INTER_VERSION >= intermediate;    }    /**     * Returns the release date of this version of Cryptix, as a string in     * the form "yyyy/mm/dd".     */    public static String getReleaseDate() {        try {            return CVS_DATE.substring(7, 17);        } catch (StringIndexOutOfBoundsException e) {            return "unknown";        }    }    /**     * Returns a string describing this version of Cryptix.     */    public static String getVersionString() {        StringBuffer version = new StringBuffer("Cryptix-Java ")            .append(MAJOR_VERSION).append(".").append(MINOR_VERSION);        if (INTER_VERSION != 0)            version.append(".").append(INTER_VERSION);        if (IS_SNAPSHOT)            version.append(" (").append(getReleaseDate()).append(" snapshot)");        return version.toString();    }    /**     * Returns English-language HTML credits for Cryptix, in a form that     * could be included in an application's About box, for example.     * <p>     * The returned string does not have &lt;HTML&gt; or &lt;BODY&gt; tags,     * so that it can easily be included in a larger page.     */    public static String getHtmlInfo() {        return HTML_INFO;    }// Main//...........................................................................    /**     * Prints the Cryptix version string, whether Cryptix is installed correctly,     * and the location of the library directory.     */    public static void main(String[] args) {        System.out.println(getVersionString());        System.out.println();        if (Security.getProvider("Cryptix") == null) {            System.out.println("Cryptix is not installed as a provider in the java.security file.");            System.out.println("Enter \"java cryptix.provider.Install\" to correct this.");        } else {            System.out.println("Cryptix is correctly installed in the java.security file.");        }        try {            String libPath = CryptixProperties.getLibraryPath();            System.out.println("The library directory is");            System.out.println("  " + libPath);        } catch (IOException e) {            e.printStackTrace();        }    }//// The rest of this class should mirror the corresponding code in// java.security.IJCE_Properties.//...........................................................................// Constants and vars.//...........................................................................    /**     * The common name for this class library. This is used for error messages,     * because most of the code for this class is duplicated between Cryptix     * and IJCE.     */    static final String PRODUCT_NAME = "Cryptix";    /**     * The name of the directory in which the properties files and (if     * applicable) native libraries are found.     */    static final String LIB_DIRNAME = "cryptix-lib";    /**     * The names of the properties files.     */    static final String[] PROPERTIES_FILES = { "Cryptix.properties", "Local.properties" };    /**     * A global, private Properties object.     */    private static final Properties properties = new Properties();    /**     * The full actual path (ending with LIB_DIRNAME and a file separator)     * of the library directory. lib_path is null if an error occurred during     * initialization, before the path was determined.     */    private static String lib_path; // defaults to null// Static code//...........................................................................    static {        setProperties();    }// Own methods//...........................................................................    /**     * Returns the path of the library directory. The name of this directory     * is given by the LIB_DIRNAME constant.     * <p>     * The returned path is always absolute, and ends with a file separator     * character (e.g. "/" on Unix).     *     * @exception IOException if an error occurred during intialization,     *            preventing the path from being determined.     */    public static String getLibraryPath() throws IOException {        // lib_path cannot change after class initialization.        if (lib_path == null) throw new IOException(PRODUCT_NAME + " library directory (" +            LIB_DIRNAME + ") could not be found");        return lib_path;    }    /**     * Loads the properties file.     */    private static void setProperties() {        try { PrivilegeManager.enablePrivilege("UniversalPropertyRead"); }        catch (NoClassDefFoundError e) {}               String fs = System.getProperty("file.separator");               try { PrivilegeManager.revertPrivilege("UniversalPropertyRead"); }        catch (NoClassDefFoundError e) {}                try { PrivilegeManager.enablePrivilege("UniversalFileRead"); }        catch (NoClassDefFoundError e) {}        boolean loaded = false;                       for (int i = 0; i < PROPERTIES_FILES.length; i++) {             InputStream props = CryptixProperties.class.getResourceAsStream                                  (fs + LIB_DIRNAME + fs + PROPERTIES_FILES[i]);            if (props != null) {                try {                    properties.load(props);                    loaded = true;                } catch (IOException ioe) {                    ioe.printStackTrace();                }            }            // also try to find without the LIB_DIRNAME                        props = CryptixProperties.class.getResourceAsStream                                  (fs + PROPERTIES_FILES[i]);                    if (props != null) {                try {                    properties.load(props);                    loaded = true;                } catch (IOException ioe) {                    ioe.printStackTrace();                }            }                                    // and in the META-INF dir            props = CryptixProperties.class.getResourceAsStream                                  (fs + "META-INF" + fs + PROPERTIES_FILES[i]);                    if (props != null) {                try {                    properties.load(props);                    loaded = true;                } catch (IOException ioe) {                    ioe.printStackTrace();                }            }            // and finally in my own dir ( /cryptix/ )            props = CryptixProperties.class.getResourceAsStream                                  (PROPERTIES_FILES[i]);                    if (props != null) {                try {                    properties.load(props);                    loaded = true;                } catch (IOException ioe) {                    ioe.printStackTrace();                }            }        }        try { PrivilegeManager.revertPrivilege("UniversalFileRead"); }        catch (NoClassDefFoundError e) {}               if ( !loaded ) {            System.err.println(                "Warning: failed to load the " + PRODUCT_NAME + " properties file.\n" +                "Make sure that the CLASSPATH entry for " + PRODUCT_NAME + " is an absolute path.");        }    }    /**     * Saves the properties to the OutputStream <i>os</i>, in the format     * used by <code>java.util.Properties.save</code>. The string <i>comment</i>     * is written as a comment in the first line of the output.     */    public static void save(OutputStream os, String comment) {        properties.save(os, comment);    }    /**     * Gets the value of a property.     */    public static String getProperty(String key) {        return properties.getProperty(key);    }    /**     * Gets the value of a property, or returns <i>defaultValue</i> if the     * property was not set.     */    public static String getProperty(String key, String defaultValue) {        return properties.getProperty(key, defaultValue);    }    /**     * Returns an enumeration of all the property names.     */    public static Enumeration propertyNames() {        return properties.propertyNames();    }    /**     * Lists the properties to the PrintStream <i>out</i>.     */    public static void list(PrintStream out) {        properties.list(out);    }    /**     * Lists the properties to the PrintWriter <i>out</i>.     */    public static void list(PrintWriter out) {        properties.list(out);    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -