📄 tools.java
字号:
package cn.com.iaspec.workflow.organize.ext;
import java.io.*;
import java.util.*;
public class Tools{
public Tools(){
}
/**
* 转换一个字符串以分隔符分开的字符组合成数组
* @param myStr 要分隔的字符串
* @param separator 分隔符
* @return 转化后的数组
*/
public static String[] split(String myStr,String separator){
if(myStr==null){
return null;
}
StringTokenizer token=new StringTokenizer(myStr,separator);
String[] returnArry=new String[token.countTokens()];
int counter=0;
while(token.hasMoreTokens()){
returnArry[counter++]=token.nextToken();
}
return returnArry;
}
/**
* 返回当前系统变量的函数,结果放在一个Properties里边,这里只针对win2k以上的,其它系统可以自己改进
* @throws Exception
* @return Properties
*/
public static Properties getEnv()
throws Exception{
Properties prop=new Properties();
String os=System.getProperty("os.name").toLowerCase();
Process p=null;
System.out.println("is name is:"+os);
if(os.indexOf("windows")>-1){
p=Runtime.getRuntime().exec("cmd /c set"); //其它的操作系统可以自行处理,这里是win2k
} else {
p=Runtime.getRuntime().exec("env"); //unix,linux操作系统
}
BufferedReader br=new BufferedReader(new InputStreamReader(p.getInputStream()));
String line;
while((line=br.readLine())!=null){
int i=line.indexOf("=");
if(i>-1){
String key=line.substring(0,i);
String value=line.substring(i+1);
prop.setProperty(key,value);
}
}
return prop;
}
public static String getOrgPropertiesFilePanth()
throws Exception{
String fileName="\\";
fileName=getEnv().getProperty("SUNFLOW_HOME");
//如果路径名后不是“\”
if(fileName!=null&&fileName.length()>0){
if(!fileName.substring(fileName.length()-1).equals(System.getProperty("file.separator"))){
fileName=fileName+System.getProperty("file.separator");
}
}
else{
fileName=fileName+System.getProperty("file.separator");
}
System.out.println("fileName path is:"+fileName);
return fileName+"org_connect.properties";
}
public static void main(String[] args)
throws Exception{
System.out.println("fileName is:"+getOrgPropertiesFilePanth());
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -