亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? systemvariable.java

?? 為了下東西 隨便發了個 datamining 的源代碼
?? JAVA
字號:
/*
 *    This program is free software; you can redistribute it and/or modify
 *    it under the terms of the GNU General Public License as published by
 *    the Free Software Foundation; either version 2 of the License, or
 *    (at your option) any later version.
 *
 *    This program is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *    GNU General Public License for more details.
 *
 *    You should have received a copy of the GNU General Public License
 *    along with this program; if not, write to the Free Software
 *    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */
/*
 * Created on 2006/8/25
 *
 * @Author: Xiaojun Chen
 * $Revision$ 1.0
 *
 */
package eti.bi.common.System;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URL;
import java.util.Enumeration;
import java.util.Properties;
import eti.bi.common.MLPropertyResourceBundle;

public class SystemVariable {
	private static String HOME;
	private static MLPropertyResourceBundle property;
	private static String[] fields = new String[0];
	private static boolean[] register = new boolean[0];
	
	public static void initialize() {
		HOME = SysConfig.getProperty("SYSTEM_VARIABLE_HOME");
		File homedir = new File(HOME);
		if (!homedir.exists()) {
			if (!homedir.mkdirs()) {
				System.err.println("Can't create system variable dir: " + HOME);
				SysLog.warn("Can't create system variable dir: " + HOME);
				return;
			}
		}
		// load system variable
		String filepath = HOME + File.separator + "system.properties";
		File file = new File(filepath);
		if (!file.exists()) {
			System.err.println("SysTem property file: " + filepath + " dosen't exist!");
			SysLog.warn("SysTem property file: " + filepath + " dosen't exist!");
			return;
		}
		try {
			FileInputStream is = new FileInputStream(file);
			property = new MLPropertyResourceBundle();
			property.addResource(is);
			is.close();
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			SysLog.warn("Registering the system variable fail!", e);
		}
		// load other variable
		File[] files = homedir.listFiles();
		if (files == null) {
			SysLog.info("No other fields of system variable!");
			return;
		}
		String temp;
		String[] temp_fileds = new String[files.length];
		int i,index = 0;
		for (i = 0; i < files.length; i++) {
			temp = files[i].getName();
			if ((!temp.endsWith("system.properties") && temp.endsWith(".properties"))) {
				temp_fileds[index] = temp.replaceAll(".properties", "");
				
				try {
					InputStream in = new FileInputStream(files[i]);
					Properties properties = new Properties();
					properties.load(in);
					in.close();
					Enumeration enu = properties.keys();
					String key;
					while (enu.hasMoreElements()) {
						key = (String) enu.nextElement();
						try {
							property.addProperty(temp_fileds[index] + "_" + key, properties.getProperty(key));
						} catch (Exception e) {
							e.printStackTrace();
							SysLog.warn("Registering the key: " + key + " of " + temp_fileds[index] + "from file: "
									+ files[i].getAbsolutePath() + " fail!");
						}
					}
				} catch (Exception e) {
					e.printStackTrace();
					SysLog.warn("Registering the property file: "+files[i].getAbsolutePath()+" fail!",e);
				}
				index++;
			}
		}
		
		fields = new String[index];
		register = new boolean[index];
		for(i=0;i<index;i++) {
			fields[i] = temp_fileds[i];
			register[i] = false;
		}
	}

	private static void registerFileProperty(Properties properties, String field) {
		Enumeration enu = properties.keys();
		String key;
		while (enu.hasMoreElements()) {
			key = (String) enu.nextElement();
			try {
				property.addProperty( field + "_" + key, properties.getProperty(key));
			} catch (Exception e) {
				e.printStackTrace();
				SysLog.warn("Registering the key: " + key + " of " + field + " fail!");
			}
		}
		
		String[] temp_fields = new String[fields.length+1];
		boolean[] temp_register = new boolean[fields.length+1];
		for(int i=0;i<fields.length;i++) {
			temp_fields[i] = fields[i];
			temp_register[i]= register[i];
		}
		temp_fields[fields.length] = field;
		temp_register[fields.length] = true;
		fields = temp_fields;
		register = temp_register;
	}
	
	private static boolean registerField(String field) {
		int len = fields.length;
		for(int i=0;i<len;i++) {
			if(fields[i].equals(field)) {
				register[i] = true;
				return true;
			}
		}
		return false;
	}
	
	/**
	 * add a system variable properties to root system viariable property file
	 * 
	 * @param afile
	 *            the Properties file added
	 * @param field
	 *            the field of system viariable Property, null for the system
	 *            variable. If this file is in a plug-in, the name should be the
	 *            file name of the plug-in.
	 * @throws Exception 
	 */
	public static void addViariableProperty(String afile, String field) throws Exception {
		
		if(hasField(field)) {
			registerField(field);
			return;
		}
		
		if (field != null) {
			File file = new File(afile);
			if (!file.exists()) {
				throw new FileNotFoundException("File propertyfile not found!");
			}
			if (!file.isFile()) {
				throw new FileNotFoundException(afile + " should be a file!");
			}

			File newFile = copyFile(file, field);
			Properties properties = openProperty(newFile);
			registerFileProperty(properties, field);
			
		} else {
			property.addResource(afile);
		}
	}
	
	

	/**
	 * add a system variable property file to root system viariable property
	 * file
	 * 
	 * @param in
	 *            input stream of property file to add
	 * @param field
	 *            the field of system viariable Property, null for the system
	 *            variable. If this input stream in is from a plug-in, the name
	 *            should be the file name of the plug-in.
	 * @throws Exception 
	 */
	public static void addViariableProperty(InputStream in, String field) throws Exception {
		
		if(hasField(field)) {
			registerField(field);
			return;
		}
		
		if (field != null) {
			
			File newFile = copyInputStream(in, field);
			Properties properties = openProperty(newFile);
			registerFileProperty(properties, field);
			
		} else {
			property.addResource(in);
		}
	}
	
	/**
	 * add a system variable properties to root system viariable property file
	 * 
	 * @param properties
	 *            the Properties added
	 * @param field
	 *            the field of system viariable Property, null for the system
	 *            variable. If the properties is form a plug-in, the name should
	 *            be the file name of the plug-in.
	 * @throws Exception
	 */
	public static void addVariableProperty(Properties properties, String field) throws Exception {
		if(hasField(field)) {
			registerField(field);
			return;
		}
		
		if (field != null) {
			File newFile = copyProperty(properties, field);
			Properties propert = openProperty(newFile);
			registerFileProperty(propert, field);
		} else {
			property.addResource(properties);
		}
	}

	/**
	 * add a system variable properties to root system viariable property file
	 * 
	 * @param url
	 *            the Properties URL added.
	 * @param field
	 *            the field of system viariable Property, null for the system
	 *            variable. If the url is from a plug-in, the name should be the
	 *            file name of the plug-in.
	 * @throws Exception
	 */
	public static void addVariableProperty(URL url, String field) throws Exception {
		if(hasField(field)) {
			registerField(field);
			return;
		}
		
		if (field != null) {
			File newFile = copyURL(url, field);
			Properties properties = openProperty(newFile);
			registerFileProperty(properties, field);
		} else {
			property.addResource(url);
		}
	}

	public static File copyFile(File file, String field) throws Exception{
		File newFile = new File(HOME+File.separator+field+".properties");
		if(newFile.exists()) {
			throw new IOException("The variable file of field "+field+" already exists!");
		}
		
		InputStream in = null;
		OutputStream ou = null;
		try {
			in = new FileInputStream(file);
			
			ou = new FileOutputStream(newFile);
			byte[] bytes = new byte[5000];
			int read = 0;
			int size = in.available();
			int hasread = 0;
			int step = 0;
			
			while(hasread<size) {
				read=0;
				step = 5000>(size-hasread)?(size-hasread):5000;
				while(read<step) {
					read += in.read(bytes, read, step-read);
				}
				hasread += read;
				ou.write(bytes, 0, read);
			}
		}
		catch(Exception e) {
			e.printStackTrace();
			return null;
		}
		finally {
			try{
				if(in!=null) {
					in.close();
				}
				if(ou!=null) {
					ou.close();
				}
			}
			catch(Exception e) {
				e.printStackTrace();
			}
		}
		
		return newFile;
	}
	
	public static File copyInputStream(InputStream in, String field) throws Exception{
		File newFile = new File(HOME+File.separator+field+".properties");
		if(newFile.exists()) {
			throw new IOException("The variable file of field "+field+" already exists!");
		}
		
		OutputStream ou = new FileOutputStream(newFile);
		
		try {
			
			ou = new FileOutputStream(newFile);
			byte[] bytes = new byte[5000];
			int read = 0;
			int size = in.available();
			int hasread = 0;
			int step = 0;
			
			while(hasread<size) {
				read=0;
				step = 5000>(size-hasread)?(size-hasread):5000;
				while(read<step) {
					read += in.read(bytes, read, step-read);
				}
				hasread += read;
				ou.write(bytes, 0, read);
			}
		}
		catch(Exception e) {
			e.printStackTrace();
			return null;
		}
		finally {
			try{
				if(ou!=null) {
					ou.close();
				}
			}
			catch(Exception e) {
				e.printStackTrace();
			}
		}
		
		return newFile;
	}
	
	public static File copyProperty(Properties properties, String field) throws Exception{
		File newFile = new File(HOME+File.separator+field+".properties");
		if(newFile.exists()) {
			throw new IOException("The variable file of field "+field+" already exists!");
		}
		
		OutputStream ou = new FileOutputStream(newFile);
		properties.store(ou, null);
		ou.close();
		
		return newFile;
	}
	
	private static File copyURL(URL url, String field) throws Exception{
		File newFile = new File(HOME+File.separator+field+".properties");
		if(newFile.exists()) {
			throw new IOException("The variable file of field "+field+" already exists!");
		}
		
		InputStream in = null;
		OutputStream ou = new FileOutputStream(newFile);
		
		try {
			in = url.openStream();
			ou = new FileOutputStream(newFile);
			byte[] bytes = new byte[5000];
			int read = 0;
			int size = in.available();
			int hasread = 0;
			int step = 0;
			
			while(hasread<size) {
				read=0;
				step = 5000>(size-hasread)?(size-hasread):5000;
				while(read<step) {
					read += in.read(bytes, read, step-read);
				}
				hasread += read;
				ou.write(bytes, 0, read);
			}
		}
		catch(Exception e) {
			e.printStackTrace();
			return null;
		}
		finally {
			try{
				if(in!=null) {
					in.close();
				}
				if(ou!=null) {
					ou.close();
				}
			}
			catch(Exception e) {
				e.printStackTrace();
			}
		}
		
		return newFile;
	}
	
	private static Properties openProperty(File file) throws Exception{
		InputStream in = new FileInputStream(file);
		Properties properties = new Properties();
		properties.load(in);
		in.close();
		return properties;
	}
	
	/**
	 * Get the system property for a give key.
	 * 
	 * @param key
	 *            the key for the desired string
	 * @param field
	 *            the field of system viariable Property, null for the system
	 *            variable.
	 * @return the system property for a give key.
	 */
	public static String getSystemProperty(String key ) {
		if (property == null) {
			return null;
		} else {
			try {
				return property.getString(key);
			} catch (Exception e) {
				e.printStackTrace();
				return null;
			}
		}
	}
	
	/**
	 * Get the field property for a give key.
	 * 
	 * @param key
	 *            the key for the desired string
	 * @param field
	 *            the field of system viariable Property, null for the system
	 *            variable.
	 * @return the system property for a give key.
	 */
	public static String getFieldProperty(String key, String field) {
		if (property == null) {
			return null;
		} else {
			try {
				if (field != null) {
					return property.getString(field + "_" + key);
				}
				return property.getString(key);
			} catch (Exception e) {
				e.printStackTrace();
				return null;
			}
		}
	}
	
	public static String getAllProperty(String key) {
		String value = property.getString(key);
		if(value!=null) {
			return value;
		}
		for(int i=0;i<fields.length;i++) {
			value = property.getString(fields[i] + "_" + key);
			if(value!=null) {
				return value;
			}
		}
		return null;
	}
	
	public static Properties getAllProperties() {
		return property.getProperties();
	}
	
	/**
	 * get the property of the specific field
	 * @param field 
	 *				the field of system viariable Property, null for the system
	 *           	variable. If the url is from a plug-in, the name should be the
	 *            	file name of the plug-in.
	 * @return the properties of the specific field, null if no properties of this field
	 * */
	public static Properties getFieldProperties(String field) {
		if(!hasField(field)) {
			return null;
		}
		Properties prop = new Properties();
		String file = HOME+File.separator+field+".properties";
		InputStream in = null;
		try {
			File temp = new File(file);
			in = new FileInputStream(temp);
			prop.load(in);
		}
		catch(Exception e) {
			e.printStackTrace();
		}
		finally {
			if(in!=null){
				try {
					in.close();
				} catch (IOException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
		}
		return prop;
	}
	
	public static boolean hasField(String field) {
		int len = fields.length;
		for(int i=0;i<len;i++) {
			if(fields[i].equals(field)) {
				return true;
			}
		}
		return false;
	}
	
	public static void Clean() {
		if(fields==null) {
			return;
		}
		int len = register.length;
		for(int i=0;i<len;i++) {
			if(!register[i]) {
				String file = HOME+File.separator+fields[i]+".properties";
				File deleteFile = new File(file);
				deleteFile.delete();
			}
		}
	}
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产精品日韩精品欧美在线| 6080亚洲精品一区二区| 久久久综合激的五月天| 国产一区视频在线看| 国产欧美一区二区三区在线看蜜臀 | 日韩专区在线视频| 欧美另类久久久品| 麻豆视频观看网址久久| 久久午夜电影网| 成人黄色大片在线观看| 亚洲精选视频免费看| 欧美精品三级日韩久久| 国模少妇一区二区三区| 中文字幕一区二区三区视频| 在线观看免费亚洲| 日本欧洲一区二区| 久久精品在这里| 欧美亚洲国产一区二区三区va| 丝瓜av网站精品一区二区| 久久天天做天天爱综合色| 91在线porny国产在线看| 天堂va蜜桃一区二区三区 | 国产成人鲁色资源国产91色综 | 久久国产精品99精品国产| 久久精品欧美日韩精品| 91久久精品网| 黄色精品一二区| 亚洲一二三专区| 2020国产精品| 欧美艳星brazzers| 国产91在线看| 亚洲午夜久久久久| 国产亚洲综合色| 欧美日韩国产片| 成人av资源下载| 玖玖九九国产精品| 亚洲国产精品精华液网站| 久久免费视频色| 宅男在线国产精品| 色综合天天综合网天天看片| 激情亚洲综合在线| 偷偷要91色婷婷| 亚洲图片激情小说| 久久久精品欧美丰满| 欧美精品久久99| 在线观看av一区| 99re视频这里只有精品| 激情久久久久久久久久久久久久久久| 亚洲美女精品一区| 国产精品久久久久久久久免费相片 | 91免费国产视频网站| 精品夜夜嗨av一区二区三区| 亚洲午夜精品网| 中文字幕在线观看不卡| 久久影院午夜论| 日韩一区二区中文字幕| 欧美亚洲国产一区二区三区va| 丁香激情综合国产| 国产精品综合在线视频| 日韩在线a电影| 亚洲超碰97人人做人人爱| 亚洲日本电影在线| 国产精品免费av| 国产视频一区二区在线| 精品日产卡一卡二卡麻豆| 日韩一区二区高清| 制服丝袜亚洲色图| 欧美一区二区免费观在线| 欧美午夜精品一区| 欧美专区在线观看一区| 色综合久久中文综合久久97| 成人动漫一区二区在线| 国产成人午夜电影网| 国产999精品久久久久久| 国产精品主播直播| 国产精品99久久久久久似苏梦涵| 久久疯狂做爰流白浆xx| 蓝色福利精品导航| 国产精品自在欧美一区| 国产精品资源网| 成人激情午夜影院| 91美女在线观看| 欧美视频一区二区三区四区| 欧美三级资源在线| 欧美日韩午夜在线| 欧美一级免费大片| 久久只精品国产| 国产日本欧洲亚洲| 国产精品久久久久久亚洲毛片| 欧美韩国日本不卡| 亚洲视频一区在线| 亚洲18色成人| 激情久久五月天| 成人av午夜影院| 色狠狠色狠狠综合| 在线播放亚洲一区| 精品国偷自产国产一区| 中文字幕欧美日本乱码一线二线| 国产精品国产成人国产三级 | 91精品国产91热久久久做人人 | 裸体歌舞表演一区二区| 激情五月婷婷综合网| 播五月开心婷婷综合| 欧美私模裸体表演在线观看| 日韩欧美区一区二| 欧美激情一区在线观看| 亚洲h在线观看| 国产精品一二三四| 91福利国产精品| 欧美大胆人体bbbb| 亚洲图片激情小说| 久久精品免费观看| 色哟哟一区二区在线观看| 欧美一区二区日韩| 亚洲私人影院在线观看| 日韩av网站免费在线| 成人精品视频.| 911精品产国品一二三产区| 国产亚洲精久久久久久| 亚洲狠狠爱一区二区三区| 国产在线乱码一区二区三区| 色美美综合视频| 国产亚洲欧美日韩在线一区| 亚洲国产综合色| 国产91精品精华液一区二区三区| 精品视频色一区| 国产精品免费视频一区| 日韩在线一区二区三区| av在线一区二区三区| 欧美岛国在线观看| 亚洲国产aⅴ成人精品无吗| 国产精品白丝jk黑袜喷水| 欧美久久婷婷综合色| 国产精品久久久久aaaa樱花| 麻豆一区二区三区| 欧美性欧美巨大黑白大战| 久久久久久久电影| 久久精品国产亚洲一区二区三区| 色综合久久中文综合久久97| 久久久影视传媒| 免费一级欧美片在线观看| 色综合 综合色| 国产精品天干天干在观线| 久久草av在线| 欧美一卡2卡3卡4卡| 亚洲一区二区欧美日韩| 99久久国产综合色|国产精品| 精品国产成人在线影院| 日韩成人一区二区三区在线观看| 色八戒一区二区三区| 综合色中文字幕| av中文字幕不卡| 中文字幕 久热精品 视频在线| 激情六月婷婷久久| 精品国产一区二区三区久久久蜜月 | 99久久精品久久久久久清纯| 久久精品夜色噜噜亚洲a∨| 日本不卡视频在线观看| 欧美二区三区91| 午夜视频一区在线观看| 欧洲一区二区av| 亚洲电影一区二区| 欧美日韩一区不卡| 日日摸夜夜添夜夜添国产精品| 欧美性一区二区| 亚洲成人激情av| 欧美一区二区在线播放| 轻轻草成人在线| 精品国产1区二区| 激情六月婷婷综合| 欧美激情一区二区三区四区| 成人福利电影精品一区二区在线观看| 国产亚洲污的网站| 99久久精品免费看国产| 一级精品视频在线观看宜春院| 色偷偷久久一区二区三区| 亚洲美女区一区| 欧美老肥妇做.爰bbww| 日韩av一级片| 精品不卡在线视频| 国产成人综合亚洲网站| 国产精品天天看| 色噜噜狠狠色综合中国| 亚洲超丰满肉感bbw| 欧美一级日韩免费不卡| 国模冰冰炮一区二区| 国产精品色噜噜| 欧美三级中文字| 激情综合色播激情啊| 国产精品久久一卡二卡| 欧美中文一区二区三区| 日本欧美久久久久免费播放网| 精品人伦一区二区色婷婷| proumb性欧美在线观看| 亚洲国产毛片aaaaa无费看 | 亚洲视频一区二区免费在线观看 | 日韩欧美国产一区二区在线播放 | 欧美丰满美乳xxx高潮www| 狠狠色丁香婷婷综合| 国产精品第一页第二页第三页|