日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 运维知识 > windows >内容正文

windows

根据不同的操作系统读取配置文件/java读取属性文件代码

發(fā)布時(shí)間:2024/9/27 windows 25 豆豆
生活随笔 收集整理的這篇文章主要介紹了 根据不同的操作系统读取配置文件/java读取属性文件代码 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

package cn.com.css.common.util;

/**
?* @brief OSEnum.java 操作系統(tǒng)的枚舉
?* @attention
?* @author 涂作權(quán)
?* @date 2014年4月3日
?* @note begin modify by null
?*/
public enum EOSPlatForm {
?Any("any"),
?Linux("Linux"),
?Mac_OS("Mac OS"),
?Mac_OS_X("Mac OS X"),
?Windows("Windows"),
?OS2("OS/2"),
?Solaris("Solaris"),
?SunOS("SunOS"),
?MPEiX("MPE/iX"),
?HP_UX("HP-UX"),
?AIX("AIX"),
?OS390("OS/390"),
?FreeBSD("FreeBSD"),
?Irix("Irix"),
?Digital_Unix("Digital Unix"),
?NetWare_411("NetWare"),
?OSF1("OSF1"),
?OpenVMS("OpenVMS"),
?Others("Others");

?/** 描述信息 **/
?private String description;

?/**
? * @param desc 描述信息
? */
?EOSPlatForm(String desc) {
??this.description = desc;
?}

?public String getDescription() {
??return description;
?}

?public void setDescription(String description) {
??this.description = description;
?}
}

?

package cn.com.css.common.util;

/**
?* @brief OSInfo.java 通過(guò)這個(gè)類獲得操作信息信息
?* @attention
?* @author 涂作權(quán)
?* @date 2014年4月3日
?* @note begin modify by null
?*/
public class OSInfo {
?/** 操作系統(tǒng)名稱 **/
?private static String OS_NAME = System.getProperty("os.name").toLowerCase();
?private static OSInfo osInfoInstance = new OSInfo();
?private EOSPlatForm osPlatForm;

?private OSInfo() {
?}

?/**
? * \brief 判斷是否是Linux操作系統(tǒng)
? *
? * @return
? * @attention
? * @author 涂作權(quán)
? * @date 2014年4月3日
? * @note begin modify by null
? */
?public static boolean isLinux() {
??return OS_NAME.indexOf("linux") >= 0;
?}

?/**
? * \brief 判斷是否是MacOS操作系統(tǒng)
? *
? * @return
? * @attention
? * @author 涂作權(quán)
? * @date 2014年4月3日
? * @note begin modify by null
? */
?public static boolean isMacOS() {
??return OS_NAME.indexOf("mac") >= 0 && OS_NAME.indexOf("os") > 0
????&& OS_NAME.indexOf("x") < 0;
?}

?/**
? * \brief 判斷是否是MacOSX操作系統(tǒng)
? *
? * @return
? * @attention
? * @author 涂作權(quán)
? * @date 2014年4月3日
? * @note begin modify by null
? */
?public static boolean isMacOSX() {
??return OS_NAME.indexOf("mac") >= 0 && OS_NAME.indexOf("os") > 0
????&& OS_NAME.indexOf("x") > 0;
?}

?/**
? * \brief 判斷是否是windows操作系統(tǒng)
? *
? * @return
? * @attention
? * @author 涂作權(quán)
? * @date 2014年4月3日
? * @note begin modify by null
? */
?public static boolean isWindows() {
??return OS_NAME.indexOf("windows") >= 0;
?}

?/**
? * \brief 判斷是否是OS2操作系統(tǒng)
? *
? * @return
? * @attention 方法的使用注意事項(xiàng)
? * @author Administrator
? * @date 2014-4-3
? * @note begin modify by 修改人 修改時(shí)間 修改內(nèi)容摘要說(shuō)明
? */
?public static boolean isOS2() {
??return OS_NAME.indexOf("os/2") >= 0;
?}

?public static boolean isSolaris() {
??return OS_NAME.indexOf("solaris") >= 0;
?}

?public static boolean isSunOS() {
??return OS_NAME.indexOf("sunos") >= 0;
?}

?public static boolean isMPEiX() {
??return OS_NAME.indexOf("mpe/ix") >= 0;
?}

?public static boolean isHPUX() {
??return OS_NAME.indexOf("hp-ux") >= 0;
?}

?public static boolean isAix() {
??return OS_NAME.indexOf("aix") >= 0;
?}

?public static boolean isOS390() {
??return OS_NAME.indexOf("os/390") >= 0;
?}

?public static boolean isFreeBSD() {
??return OS_NAME.indexOf("freebsd") >= 0;
?}

?public static boolean isIrix() {
??return OS_NAME.indexOf("irix") >= 0;
?}

?public static boolean isDigitalUnix() {
??return OS_NAME.indexOf("digital") >= 0 && OS_NAME.indexOf("unix") > 0;
?}

?public static boolean isNetWare() {
??return OS_NAME.indexOf("netware") >= 0;
?}

?public static boolean isOSF1() {
??return OS_NAME.indexOf("osf1") >= 0;
?}

?public static boolean isOpenVMS() {
??return OS_NAME.indexOf("openvms") >= 0;
?}

?/**
? * \brief 獲得操作系統(tǒng)的名稱
? *
? * @return
? * @attention
? * @author 涂作權(quán)
? * @date 2014年4月3日
? * @note begin modify by null
? */
?public static EOSPlatForm getOSName() {
??if (isAix()) {
???osInfoInstance.osPlatForm = EOSPlatForm.AIX;
??} else if (isDigitalUnix()) {
???osInfoInstance.osPlatForm = EOSPlatForm.Digital_Unix;
??} else if (isFreeBSD()) {
???osInfoInstance.osPlatForm = EOSPlatForm.FreeBSD;
??} else if (isHPUX()) {
???osInfoInstance.osPlatForm = EOSPlatForm.HP_UX;
??} else if (isIrix()) {
???osInfoInstance.osPlatForm = EOSPlatForm.Irix;
??} else if (isLinux()) {
???osInfoInstance.osPlatForm = EOSPlatForm.Linux;
??} else if (isMacOS()) {
???osInfoInstance.osPlatForm = EOSPlatForm.Mac_OS;
??} else if (isMacOSX()) {
???osInfoInstance.osPlatForm = EOSPlatForm.Mac_OS_X;
??} else if (isMPEiX()) {
???osInfoInstance.osPlatForm = EOSPlatForm.MPEiX;
??} else if (isNetWare()) {
???osInfoInstance.osPlatForm = EOSPlatForm.NetWare_411;
??} else if (isOpenVMS()) {
???osInfoInstance.osPlatForm = EOSPlatForm.OpenVMS;
??} else if (isOS2()) {
???osInfoInstance.osPlatForm = EOSPlatForm.OS2;
??} else if (isOS390()) {
???osInfoInstance.osPlatForm = EOSPlatForm.OS390;
??} else if (isOSF1()) {
???osInfoInstance.osPlatForm = EOSPlatForm.OSF1;
??} else if (isSolaris()) {
???osInfoInstance.osPlatForm = EOSPlatForm.Solaris;
??} else if (isSunOS()) {
???osInfoInstance.osPlatForm = EOSPlatForm.SunOS;
??} else if (isWindows()) {
???osInfoInstance.osPlatForm = EOSPlatForm.Windows;
??} else {
???osInfoInstance.osPlatForm = EOSPlatForm.Others;
??}
??return osInfoInstance.osPlatForm;
?}

//?public static void main(String[] args) {
//??System.out.println(OSInfo.getOSName());
//??System.out.println(osInfoInstance.osPlatForm.getDescription());
//??System.out.println(System.getProperty("os.name"));
//??System.out.println(System.getProperty("os.version"));
//??System.out.println(System.getProperty("os.arch"));
//?}
}

?

?

package cn.com.css.misps.graph.util;

import java.io.File;
import java.io.InputStream;
import java.util.Calendar;
import java.util.Date;
import java.util.Properties;

import cn.com.css.common.util.OSInfo;

/**
?* @brief StoragePathUtils.java 圖形產(chǎn)品存儲(chǔ)相關(guān)的類
?* @attention 要注意的是:圖形產(chǎn)品的存儲(chǔ)路徑要兼容Linux的。
?* @author 涂作權(quán)
?* @date 2013-9-23
?* @note begin modify by null
?*/
public final class ProductsStorageUtils {
?
?public static Calendar calendar;

?// 圖形產(chǎn)品對(duì)應(yīng)的絕對(duì)路徑
?public static String graphAbsolutePath;
?// 圖形產(chǎn)品中對(duì)應(yīng)的虛擬路徑
?public static String graphVirtualPath;
?// 文字產(chǎn)品對(duì)應(yīng)的絕對(duì)路徑
?public static String wordAbsolutePath;
?// 文字產(chǎn)品對(duì)應(yīng)的虛擬路徑
?public static String wordVirtualPath;
?// micaps磁盤(pán)掛接過(guò)來(lái)的源文件的路徑
?public static String micapsAbsolutePath;
?// micaps虛擬路徑
?public static String micapsVirtualPath;

?// 圖形產(chǎn)品今天的文件存儲(chǔ)路徑
?public static String graphTodayStoragePath;
?// 圖形產(chǎn)品明天的文件存儲(chǔ)路徑
?public static String graphTomorrowStoragePath;
?// 圖形產(chǎn)品文件存儲(chǔ)的相對(duì)路徑
?public static String graphRelativeStoragePath;

?// 文字產(chǎn)品今天的文件存儲(chǔ)路徑
?public static String wordTodayStoragePath;
?// 文字產(chǎn)品明天的文件存儲(chǔ)路徑
?public static String wordTomorrowStoragePath;
?// 文字產(chǎn)品文件存儲(chǔ)的相對(duì)路徑
?public static String wordRelativeStoragePath;
?// 認(rèn)證文件存放的位置
?public static String authenticationPath;
?// 認(rèn)證文件存放的相對(duì)路徑
?public static String authenticationTodayPath;
?// 認(rèn)證文件第二天要存放的位置
?public static String authenticationTomorrowPath;
?
?/** graphTemp文件存儲(chǔ)的臨時(shí)目錄存儲(chǔ)位置? **/
?public static String graphTempAbsolutePath;
?/** graphTemp對(duì)應(yīng)的虛擬目錄 **/
?public static String graphTempVirtualPath;
?/** 指定數(shù)據(jù)源時(shí)間存儲(chǔ)的位置? **/
?public static String graphTempTodayStoragePath;
?/** 指定數(shù)據(jù)源第二天存儲(chǔ)的位置 **/
?public static String graphTempTomorrowStoragePath;
?/** 在臨時(shí)目錄里的相對(duì)路徑**/
?public static String graphTempRelativeStoragePath;

?public ProductsStorageUtils() {
?}
?
?/**
? * \brief 編寫(xiě)此方法的目的是獲得指定時(shí)間的這些相應(yīng)數(shù)據(jù)。
? *
? * @param date
? * @return
? * @attention 如果不調(diào)用這個(gè)方法,則表示當(dāng)天對(duì)應(yīng)的這些數(shù)據(jù)
? * @author 涂作權(quán)
? * @date 2014-5-23
? * @note begin modify by 修改人 修改時(shí)間 修改內(nèi)容摘要說(shuō)明
? */
?@SuppressWarnings("static-access")
?public static ProductsStorageUtils changeCalendar(Date date) {
??ProductsStorageUtils ps = new ProductsStorageUtils();
??ps.calendar.setTime(date);
??return ps;
?}

?/**
? * 靜態(tài)代碼塊
? */
?static {
??try {
???// 使用默認(rèn)時(shí)區(qū)和語(yǔ)言環(huán)境獲得一個(gè)日歷
???calendar = Calendar.getInstance();
???// 今年
???int year = calendar.get(Calendar.YEAR);
???// 當(dāng)月
???int month = calendar.get(Calendar.MONTH) + 1;
???// 當(dāng)天
???int day = calendar.get(Calendar.DAY_OF_MONTH);
???// 明天
???int tomorrow = day + 1;

???InputStream in = null;

???// 判斷操作系統(tǒng)類型
???switch (OSInfo.getOSName()) {
???case Windows:
????// 讀取配置文件,通過(guò)類加載的方式讀取屬性文件
????in = ProductsStorageUtils.class.getClassLoader()
??????.getResourceAsStream("windows_storagepath.properties");
????break;
???case Linux:
????in = ProductsStorageUtils.class.getClassLoader()
??????.getResourceAsStream("Linux_storagepath.properties");
????break;
???default:
????break;
???}

???Properties prop = new Properties();
???prop.load(in);

???// 圖形產(chǎn)品對(duì)應(yīng)的絕對(duì)路徑
???graphAbsolutePath = prop.getProperty("productAbsolutePath")
?????+ File.separator + "graph";
???// 圖形產(chǎn)品中對(duì)應(yīng)的虛擬路徑
???graphVirtualPath = prop.getProperty("graphVirtualPath");
???// 文字產(chǎn)品對(duì)應(yīng)的絕對(duì)路徑
???wordAbsolutePath = prop.getProperty("productAbsolutePath")
?????+ File.separator + "word";
???// 文字產(chǎn)品對(duì)應(yīng)的虛擬路徑
???wordVirtualPath = prop.getProperty("wordVirtualPath");
???// micaps磁盤(pán)掛接過(guò)來(lái)的源文件的路徑
???micapsAbsolutePath = prop.getProperty("micapsAbsolutePath");
???// micaps虛擬路徑
???micapsVirtualPath = prop.getProperty("micapsVirtualPath");
???// 圖片臨時(shí)目錄存儲(chǔ)位置
???graphTempAbsolutePath = prop.getProperty("graphTempAbsolutePath");
???graphTempVirtualPath = prop.getProperty("graphTempVirtualPath");

???// 獲取圖形產(chǎn)品文件存儲(chǔ)的根路徑
???graphTodayStoragePath = graphAbsolutePath + File.separator + year
?????+ File.separator + ((month > 9) ? month : "0" + month)
?????+ File.separator + ((day > 9) ? day : "0" + day);
???// 明天圖形產(chǎn)品文件的存儲(chǔ)路徑
???graphTomorrowStoragePath = graphAbsolutePath + File.separator
?????+ year + File.separator
?????+ ((month > 9) ? month : "0" + month) + File.separator
?????+ ((tomorrow > 9) ? tomorrow : "0" + tomorrow);
???// 圖形產(chǎn)品文件存儲(chǔ)的相對(duì)路徑
???graphRelativeStoragePath = "/" + year + "/"
?????+ ((month > 9) ? month : "0" + month) + "/"
?????+ ((day > 9) ? day : "0" + day);
???
???// 獲取臨時(shí)圖形產(chǎn)品文件存儲(chǔ)的根路徑
???graphTempTodayStoragePath = graphTempAbsolutePath + File.separator + year
?????+ File.separator + ((month > 9) ? month : "0" + month)
?????+ File.separator + ((day > 9) ? day : "0" + day);
???// 明天圖形產(chǎn)品文件的存儲(chǔ)路徑
???graphTempTomorrowStoragePath = graphTempAbsolutePath + File.separator
?????+ year + File.separator
?????+ ((month > 9) ? month : "0" + month) + File.separator
?????+ ((tomorrow > 9) ? tomorrow : "0" + tomorrow);
???// 圖形產(chǎn)品文件存儲(chǔ)的相對(duì)路徑
???graphTempRelativeStoragePath = "/" + year + "/"
?????+ ((month > 9) ? month : "0" + month) + "/"
?????+ ((day > 9) ? day : "0" + day);

???// 獲取文字產(chǎn)品文件存儲(chǔ)的根路徑
???wordTodayStoragePath = wordAbsolutePath + File.separator + year
?????+ File.separator + ((month > 9) ? month : "0" + month)
?????+ File.separator + ((day > 9) ? day : "0" + day);
???// 明天文字產(chǎn)品文件的存儲(chǔ)路徑
???wordTomorrowStoragePath = wordAbsolutePath + File.separator + year
?????+ File.separator + ((month > 9) ? month : "0" + month)
?????+ File.separator
?????+ ((tomorrow > 9) ? tomorrow : "0" + tomorrow);
???// 文字產(chǎn)品文件相對(duì)路徑
???wordRelativeStoragePath = "/" + year + "/"
?????+ ((month > 9) ? month : "0" + month) + "/"
?????+ ((day > 9) ? day : "0" + day);

???// 認(rèn)證文件存放的位置
???authenticationPath = prop.getProperty("authenticationPath");
???// 認(rèn)證文件當(dāng)天存放的位置
???authenticationTodayPath = authenticationPath + File.separator
?????+ year + File.separator
?????+ ((month > 9) ? month : "0" + month) + File.separator
?????+ ((day > 9) ? day : "0" + day);
???// 認(rèn)證文件明天存放的位置
???authenticationTomorrowPath = authenticationPath + File.separator
?????+ year + File.separator
?????+ ((month > 9) ? month : "0" + month) + File.separator
?????+ ((tomorrow > 9) ? tomorrow : "0" + tomorrow);

???// 關(guān)閉流
???in.close();
???in = null;
??} catch (Exception e) {
???e.printStackTrace();
??}
?}
?
?/**
? * \brief 創(chuàng)建圖形產(chǎn)品明天文件存儲(chǔ)的文件目錄
? *
? * @attention
? *
? * @author 涂作權(quán)
? * @date 2013-10-6
? * @note begin modify by 涂作權(quán) 2014-02-13
? */
?public static void createGraphTomorrowStorageFolder() {
??// 判斷該文件夾是否存在,如果存在就不需要?jiǎng)?chuàng)建,如果不存在就創(chuàng)建
??File storageFolder = new File(graphTomorrowStoragePath);
??if (storageFolder.exists()) {
???return;
??} else {
???// 創(chuàng)建文件夾
???storageFolder.mkdirs();
???return;
??}
?}

?/**
? * \brief 創(chuàng)建指定數(shù)據(jù)源時(shí)間的圖形產(chǎn)品明天文件存儲(chǔ)的文件目錄
? *
? * @param date:指定的數(shù)據(jù)源時(shí)間
? *
? * @attention
? *
? * @author 涂作權(quán)
? * @date 2014-5-23
? * @note begin modify by 涂作權(quán)
? */
?@SuppressWarnings("static-access")
?public static void createGraphTomorrowStorageFolder(Date date) {
??// 判斷該文件夾是否存在,如果存在就不需要?jiǎng)?chuàng)建,如果不存在就創(chuàng)建
??File storageFolder = new File(changeCalendar(date).graphTomorrowStoragePath);
??if (storageFolder.exists()) {
???return;
??} else {
???// 創(chuàng)建文件夾
???storageFolder.mkdirs();
???return;
??}
?}

?/**
? * \brief 創(chuàng)建今天的文件存儲(chǔ)路徑
? *
? * @attention
? * @author 涂作權(quán)
? * @date 2014-5-23
? * @note begin modify by 涂作權(quán)
? */
?public static void createGraphTodayStorageFolder() {
??// 判斷該文件夾是否存在,如果存在就不需要?jiǎng)?chuàng)建,如果不存在就創(chuàng)建
??File storageFolder = new File(graphTodayStoragePath);
??if (storageFolder.exists()) {
???return;
??} else {
???// 創(chuàng)建文件夾
???storageFolder.mkdirs();
???return;
??}
?}

?/**
? * \brief 創(chuàng)建指定的數(shù)據(jù)源時(shí)間的那天的文件存儲(chǔ)路徑
? *
? * @param date:指定的數(shù)據(jù)源時(shí)間
? * @attention
? * @author 涂作權(quán)
? * @date 2014-5-23
? * @note begin modify by 涂作權(quán)
? */
?@SuppressWarnings("static-access")
?public static void createGraphTodayStorageFolder(Date date) {
??// 判斷該文件夾是否存在,如果存在就不需要?jiǎng)?chuàng)建,如果不存在就創(chuàng)建
??File storageFolder = new File(
????changeCalendar(date).graphTodayStoragePath);
??if (storageFolder.exists()) {
???return;
??} else {
???// 創(chuàng)建文件夾
???storageFolder.mkdirs();
???return;
??}
?}
?
?/**
? * \brief 創(chuàng)建圖形產(chǎn)品明天文件存儲(chǔ)的文件目錄
? *
? * @attention
? *
? * @author 涂作權(quán)
? * @date 2013-10-6
? * @note begin modify by 涂作權(quán) 2014-02-13
? */
?public static void createGraphTempTomorrowStorageFolder() {
??// 判斷該文件夾是否存在,如果存在就不需要?jiǎng)?chuàng)建,如果不存在就創(chuàng)建
??File storageFolder = new File(graphTempTomorrowStoragePath);
??if (storageFolder.exists()) {
???return;
??} else {
???// 創(chuàng)建文件夾
???storageFolder.mkdirs();
???return;
??}
?}
?
?/**
? * \brief 創(chuàng)建指定數(shù)據(jù)源時(shí)間的圖形產(chǎn)品明天文件存儲(chǔ)的文件目錄
? *
? * @param date:指定的數(shù)據(jù)源時(shí)間
? *
? * @attention
? *
? * @author 涂作權(quán)
? * @date 2014-5-23
? * @note begin modify by 涂作權(quán)
? */
?@SuppressWarnings("static-access")
?public static void createGraphTempTomorrowStorageFolder(Date date) {
??// 判斷該文件夾是否存在,如果存在就不需要?jiǎng)?chuàng)建,如果不存在就創(chuàng)建
??File storageFolder = new File(changeCalendar(date).graphTempTomorrowStoragePath);
??if (storageFolder.exists()) {
???return;
??} else {
???// 創(chuàng)建文件夾
???storageFolder.mkdirs();
???return;
??}
?}
?
?/**
? * \brief 創(chuàng)建今天的文件存儲(chǔ)路徑
? *
? * @attention
? * @author 涂作權(quán)
? * @date 2014-5-23
? * @note begin modify by 涂作權(quán)
? */
?public static void createGraphTempTodayStorageFolder() {
??// 判斷該文件夾是否存在,如果存在就不需要?jiǎng)?chuàng)建,如果不存在就創(chuàng)建
??File storageFolder = new File(graphTempTodayStoragePath);
??if (storageFolder.exists()) {
???return;
??} else {
???// 創(chuàng)建文件夾
???storageFolder.mkdirs();
???return;
??}
?}
?
?/**
? * \brief 創(chuàng)建指定的數(shù)據(jù)源時(shí)間的那天的文件存儲(chǔ)路徑
? *
? * @param date:指定的數(shù)據(jù)源時(shí)間
? * @attention
? * @author 涂作權(quán)
? * @date 2014-5-23
? * @note begin modify by 涂作權(quán)
? */
?@SuppressWarnings("static-access")
?public static void createGraphTempTodayStorageFolder(Date date) {
??// 判斷該文件夾是否存在,如果存在就不需要?jiǎng)?chuàng)建,如果不存在就創(chuàng)建
??File storageFolder = new File(changeCalendar(date).graphTempTodayStoragePath);
??if (storageFolder.exists()) {
???return;
??} else {
???// 創(chuàng)建文件夾
???storageFolder.mkdirs();
???return;
??}
?}

?/**
? * \brief 創(chuàng)建文字產(chǎn)品明天文件存儲(chǔ)的文件目錄
? *
? * @attention
? *
? * @author 涂作權(quán)
? * @date 2013-10-6
? * @note begin modify by 涂作權(quán) 2014-02-13
? */
?public static void createWordTomorrowStorageFolder() {
??// 判斷該文件夾是否存在,如果存在就不需要?jiǎng)?chuàng)建,如果不存在就創(chuàng)建
??File storageFolder = new File(wordTomorrowStoragePath);
??if (storageFolder.exists()) {
???return;
??} else {
???// 創(chuàng)建文件夾
???storageFolder.mkdirs();
???return;
??}
?}

?/**
? * \brief 創(chuàng)建指定數(shù)據(jù)源時(shí)間的后一天的文件存儲(chǔ)的文件目錄
? *
? * @param date :指定的數(shù)據(jù)源時(shí)間
? *
? * @attention
? *
? * @author 涂作權(quán)
? * @date 2014-5-23
? * @note begin modify by 涂作權(quán)
? */
?@SuppressWarnings("static-access")
?public static void createWordTomorrowStorageFolder(Date date) {
??// 判斷該文件夾是否存在,如果存在就不需要?jiǎng)?chuàng)建,如果不存在就創(chuàng)建
??File storageFolder = new File(
????changeCalendar(date).wordTomorrowStoragePath);
??if (storageFolder.exists()) {
???return;
??} else {
???// 創(chuàng)建文件夾
???storageFolder.mkdirs();
???return;
??}
?}

?/**
? * \brief 創(chuàng)建文字產(chǎn)品今天的文件存儲(chǔ)路徑
? *
? * @attention
? * @author 涂作權(quán)
? * @date 2013-10-6
? * @note begin modify by 涂作權(quán) 2014-02-13
? */
?public static void createWordTodayStorageFolder() {
??// 判斷該文件夾是否存在,如果存在就不需要?jiǎng)?chuàng)建,如果不存在就創(chuàng)建
??File storageFolder = new File(wordTodayStoragePath);
??if (storageFolder.exists()) {
???return;
??} else {
???// 創(chuàng)建文件夾
???storageFolder.mkdirs();
???return;
??}
?}

?/**
? * \brief 創(chuàng)建指定數(shù)據(jù)源時(shí)間的文字產(chǎn)品所在的文件存儲(chǔ)路徑
? *
? * @attention
? * @author 涂作權(quán)
? * @date 2014-05-23
? * @note begin modify by 涂作權(quán)
? */
?@SuppressWarnings("static-access")
?public static void createWordTodayStorageFolder(Date date) {
??// 判斷該文件夾是否存在,如果存在就不需要?jiǎng)?chuàng)建,如果不存在就創(chuàng)建
??File storageFolder = new File(changeCalendar(date).wordTodayStoragePath);
??if (storageFolder.exists()){
???return;
??} else {
???// 創(chuàng)建文件夾
???storageFolder.mkdirs();
???return;
??}
?}

?/**
? * \brief 創(chuàng)建認(rèn)證文件當(dāng)天存放文件的位置
? *
? * @attention
? * @author 涂作權(quán)
? * @date 2014-3-23
? * @note begin modify by null
? */
?public static void createAuthenticationTodayFolder() {
??// 判斷該文件夾是否存在,如果存在就不需要?jiǎng)?chuàng)建,如果不存在就創(chuàng)建
??File storageFolder = new File(authenticationTodayPath);
??if (storageFolder.exists()) {
???return;
??} else {
???// 創(chuàng)建文件夾
???storageFolder.mkdirs();
???return;
??}
?}

?/**
? * \brief 創(chuàng)建認(rèn)證文件當(dāng)天存放文件的位置
? *
? * @attention
? * @author 涂作權(quán)
? * @date 2014-3-23
? * @note begin modify by null
? */
?@SuppressWarnings("static-access")
?public static void createAuthenticationTodayFolder(Date date) {
??// 判斷該文件夾是否存在,如果存在就不需要?jiǎng)?chuàng)建,如果不存在就創(chuàng)建
??File storageFolder = new File(changeCalendar(date).authenticationTodayPath);
??if (storageFolder.exists()) {
???return;
??} else {
???// 創(chuàng)建文件夾
???storageFolder.mkdirs();
???return;
??}
?}

?/**
? * \brief 創(chuàng)建認(rèn)證文件第二天應(yīng)該應(yīng)該存放的文件夾
? *
? * @attention
? * @author 涂作權(quán)
? * @date 2014-3-23
? * @note begin modify by null
? */
?public static void createAuthenticationTomorrowFolder() {
??File storageFolder = new File(authenticationTomorrowPath);
??if (storageFolder.exists()) {
???return;
??} else {
???// 創(chuàng)建文件夾
???storageFolder.mkdirs();
???return;
??}
?}

//?@SuppressWarnings("static-access")
//?public static void main(String[] args) throws IOException {
//??System.out.println(graphAbsolutePath);
//??System.out.println(graphVirtualPath);
//??System.out.println(graphRelativeStoragePath);
//??System.out.println(graphTodayStoragePath);
//??System.out.println(graphTomorrowStoragePath);
//??System.out.println(wordAbsolutePath);
//??System.out.println(wordVirtualPath);
//??System.out.println(wordRelativeStoragePath);
//??System.out.println(wordTodayStoragePath);
//??System.out.println(wordTomorrowStoragePath);
//??System.out.println(micapsAbsolutePath);
//??System.out.println(micapsVirtualPath);
//??System.out.println(authenticationPath);
//??System.out.println(authenticationTodayPath);
//??System.out.println(authenticationTomorrowPath);
//??createAuthenticationTodayFolder();
//??createAuthenticationTomorrowFolder();
//
//??System.out.println("--- test -- "
//????+ changeCalendar(new Date()).graphRelativeStoragePath);
//??System.out.println(graphTempAbsolutePath);
//??System.out.println(graphTempVirtualPath);
//??System.out.println(graphTempTodayStoragePath);
//??System.out.println(graphTempTomorrowStoragePath);
//??System.out.println(graphTempRelativeStoragePath);
//??
//??createGraphTempTodayStorageFolder();
//?}
}

?

?

總結(jié)

以上是生活随笔為你收集整理的根据不同的操作系统读取配置文件/java读取属性文件代码的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。