浅谈小偷程序之Java
来源:优易学  2011-11-19 16:39:30   【优易学:中国教育考试门户网】   资料下载   IT书店
  题外话一:如果用EditPlus作为编辑器的话如果保存的格式默认为unicode的话那么在里面写中文用resin作为应用服务器的话就可能出现报500 Servlet错误哦!主要是因为编码的问题!
  所以要注意好页面的编码问题!有时间我得作一个专题专门来讨论一下有关JSP中编码的问题哦!
  题外话二:研究如何读LINUX的服务器IP
  import java.net.InetAddress;
  import java.net.NetworkInterface;
  import java.net.SocketException;
  import java.util.Enumeration;  
  public class GetIp {
  public static void main(String[] args){
  String ip = null;
  GetIp test = new GetIp();
  try{
  ip = test.getLocalSiteIP();
  }catch(Exception e){
  System.out.print(e.toString());
  }
  System.out.print(ip);
  }
  private String getLocalSiteIP() throws Exception {
  String siteString = "";
  Enumeration netInterfaces = NetworkInterface.getNetworkInterfaces();
  while (netInterfaces.hasMoreElements()) {
  NetworkInterface ni = (NetworkInterface) netInterfaces.nextElement();
  InetAddress ip = (InetAddress) ni.getInetAddresses().nextElement();
  if (ip.isSiteLocalAddress() && !ip.isLoopbackAddress() &&
  ip.getHostAddress().indexOf(":") == -1) {
  siteString = ip.getHostAddress();
  }
  }
  return siteString;
  }
  }

责任编辑:小草

文章搜索:
 相关文章
热点资讯
资讯快报
热门课程培训