?? preferencesloader.java
字號:
package com.sutternow.swingkar.Preferences;
import java.io.*;
import java.util.Properties;
/**
* Created by IntelliJ IDEA.
* User: payne
* Date: May 5, 2003
* Time: 12:41:36 PM
* To change this template use Options | File Templates.
*/
public class PreferencesLoader {
private static final String propFilename = "prefernces.props";
public static void storePerfernces(Preferences prefs) {
String userDir = System.getProperty("user.home");
File appDir = new java.io.File(userDir + File.separator + ".swingkar" + File.separator);
if (!appDir.exists()) {
appDir.mkdir();
}
Properties props = new Properties();
props.setProperty("author", prefs.getAuthorName());
props.setProperty("company", prefs.getCompanyName());
props.setProperty("packagename", prefs.getPackageName());
props.setProperty("dateformat", prefs.getDateFormat());
try {
FileOutputStream settingsOut = new FileOutputStream(appDir.getAbsolutePath() +
File.separator + propFilename);
props.store(settingsOut, "SwingKar Prefernces");
} catch (FileNotFoundException e) {
e.printStackTrace(); //To change body of catch statement use Options | File Templates.
} catch (java.io.IOException e) {
e.printStackTrace();
}
}
public static Preferences loadPreferences() {
Preferences prefs = new Preferences();
Properties props = new Properties();
String userDir = System.getProperty("user.home");
File appDir = new java.io.File(userDir + File.separator + ".swingkar");
File propFile =new File(appDir.getAbsolutePath() + File.separator + propFilename);
if (!appDir.exists()) {
appDir.mkdir();
}
if (!propFile.exists()) {
prefs.setAuthorName("author Name");
prefs.setCompanyName("Javanic");
prefs.setPackageName("com.sutternow");
prefs.setDateFormat("MM/dd/yyyy");
} else {
try {
props.load(new FileInputStream(propFile));
prefs.setAuthorName(props.getProperty("author"));
prefs.setCompanyName(props.getProperty("company"));
prefs.setPackageName(props.getProperty("packagename"));
prefs.setDateFormat(props.getProperty("dateformat"));
} catch (Exception e) {
e.printStackTrace(); //To change body of catch statement use Options | File Templates.
}
}
return prefs;
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -