欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

测试工具2

程序员文章站 2022-07-12 18:58:26
...
     List list = new ArrayList();

     if (null != context || context.length()!=0) {
       list = StringUtil.ssplit(context);
     }

public static List ssplit(String text) {

String[] strArray = null;

List<String> list = new ArrayList<String>();

strArray = text.split("\\|", -1);

for (String str : strArray) {

  int i = str.length();

  if (str.equals("") || str.length() == 0) {

  } else {
     list.add(str);
  }

  System.out.println(str);

}

return list;

}

public static String getPort(){

String port="";

try {
  MBeanServer beanServer = ManagementFactory.getPlatformMBeanServer();
  Set<ObjectName> objectNames = beanServer.queryNames(new ObjectName("*:type=Connector,*"),
                     Query.match(Query.attr("protocol"), Query.value("HTTP/1.1")));
  port = objectNames.iterator().next().getKeyProperty("port");
     
  System.out.println("port"+port);
       
  
} catch (MalformedObjectNameException e) {
  // TODO Auto-generated catch block
  e.printStackTrace();
}
    
return port;

}

public static String getLocalIP(){
InetAddress addr = null;
try {
addr = InetAddress.getLocalHost();
} catch (UnknownHostException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

           byte[] ipAddr = addr.getAddress();      
            String ipAddrStr = "";      
            for (int i = 0; i < ipAddr.length; i++) {      
                if (i > 0) {      
                   ipAddrStr += ".";      
                }      
               ipAddrStr += ipAddr[i] & 0xFF;      
           }      
            //System.out.println(ipAddrStr);      
                   return ipAddrStr;      
   }