📄 systeminfo.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/26
*
* @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.IOException;
import java.io.PrintStream;
import java.util.Properties;
import eti.bi.exception.SysException;
public class SystemInfo {
public static void load(){
boolean log = true;
boolean err = false;
boolean out = false;
File propertyFile = new File(SysConfig.getSystemHome()+File.separator+"systeminfo.properties");
if(propertyFile.exists()) {
try {
FileInputStream property = new FileInputStream(propertyFile);
Properties prop = new Properties();
prop.load(property);
String temp;
temp = prop.getProperty("log");
if(temp!=null) {
if(temp.equalsIgnoreCase("off")) {
log = false;
}
}
temp = prop.getProperty("systemerror");
if(temp!=null) {
if(temp.equalsIgnoreCase("on")) {
err = true;
}
}
temp = prop.getProperty("systemout");
if(temp!=null) {
if(temp.equalsIgnoreCase("on")) {
out = true;
}
}
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
else {
try {
propertyFile.createNewFile();
FileInputStream property = new FileInputStream(propertyFile);
Properties prop = new Properties();
prop.load(property);
prop.setProperty("log", "on");
prop.setProperty("err", "off");
prop.setProperty("out", "off");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
if(log) {
loadSysLog();
}
if(err) {
setSystemerr();
}
if(out) {
setSystemout();
}
}
private static void loadSysLog(){
try {
SysLog.initialize();
} catch (SysException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
private static void setSystemerr() {
//set error
String errorTempFilePath = SysConfig.getSystemHome()+File.separator+"error"+File.separator+"alphaminer.error";
File errDic = new File(errorTempFilePath);
if(!errDic.exists()) {
try {
errDic.createNewFile();
} catch (IOException e) {
e.printStackTrace();
SysLog.error("Creating error output file fail!", e);
return;
}
}
try {
System.setErr(new PrintStream(errDic));
} catch (IOException e) {
e.printStackTrace();
SysLog.error("Setting system error output fail!", e);
}
}
private static void setSystemout() {
// set out
String outFilePath = SysConfig.getSystemHome()+File.separator+"out"+File.separator+"alphaminer.out";
File outDic = new File(outFilePath);
if(!outDic.exists()) {
try {
outDic.createNewFile();
} catch (IOException e) {
e.printStackTrace();
SysLog.error("Creating out output file fail!", e);
return;
}
}
try {
System.setOut(new PrintStream(outDic));
} catch (IOException e) {
e.printStackTrace();
SysLog.error("Setting system out output fail!", e);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -