java »ñµÃ ip µØÖ·
Ò»°ãÇé¿ö»ñµÃ±¾µØËùÓеÄipµØÖ·£º
try {
InetAddress address = InetAddress.getLocalHost();
System.out.println(address.getHostAddress());
String name = address.getHostName();
System.out.println(name);
InetAddress[] addresses = InetAddress.getAllByName(name);
for(int i=0;i <addresses.length;i++)
System.out.println(addresses[i].getHostAddress());
}
catch(UnknownHostException uhe) {
System.err.println( "Unable to find IP ");
}
}
try {
InetAddress address = InetAddress.getLocalHost();
System.out.println(address.getHostAddress());
String name = address.getHostName();
System.out.println(name);
InetAddress[] addresses = InetAddress.getAllByName(name);
for(int i=0;i <addresses.length;i++)
System.out.println(addresses[i].getHostAddress());
}
catch(UnknownHostException uhe) {
System.err.println( "Unable to find IP ");
}
}
µ«ÊÇÒÔÉÏ·½·¨ÔÚlinuxÏÂÊDz»Ðеģ¬
Ïà¹ØÎĵµ£º
public void sort(int[] array) {
for(int i=0; i<array.length; i++) {
boolean flag = true;
for(int j=0; j<array.length-i-1; j++) {
if(array[j]>array[j+1]) {
int tmp = ar ......
ÕâÊÇһƪ¹ØÓÚ±àÂëµÄÎÄÕÂдµÄºÜºÃ!
ÊÀ½çÉϵĸ÷µØÇø¶¼Óб¾µØµÄÓïÑÔ¡£µØÇø²îÒìÖ±½Óµ¼ÖÂÁËÓïÑÔ»·¾³µÄ²îÒì¡£ÔÚ¿ª·¢Ò»¸ö¹ú¼Ê»¯³ÌÐòµÄ¹ý³ÌÖУ¬´¦ÀíÓïÑÔÎÊÌâ¾ÍÏԵúÜÖØÒªÁË¡£
¡¡¡¡ÕâÊÇÒ»¸öÊÀ½ç·¶Î§ÄÚ¶¼´æÔÚµÄÎÊÌ⣬ËùÒÔ£¬JavaÌṩÁËÊÀ½çÐԵĽâ¾ö·½·¨¡£±¾ÎÄÃèÊöµÄ·½·¨ÊÇÓÃÓÚ´¦ÀíÖÐÎĵģ¬µ«ÊÇ£¬Íƶø¹ãÖ®£¬¶ÔÓÚ´¦À ......
StringBuilder path = new StringBuilder(request.getScheme());
path.append("://").append(request.getServerName());
path.append(":").append(request.getServerPort()).append(request.getContextPath());
System.out.println("***********path:" + path);
Syste ......
²Î¿¼ÍøÉϵÄһЩ×ÊÁÏ£¬×Ô¼ºÑжÁÁËÒ»·¬£¬ÓÃjava¹¹ÔìÁËÒ»¸ö¶þ²æÊ÷À࣬²¢´øÓвâÊÔµÄmain·½·¨£¬ÈçÓв»×ãÇë´ó¼Ò¶à¶àÖ¸½Ì¡£
/**
* ¶þ²æÊ÷¹¹ÔìËã·¨
* ¶þ²æÊ÷¶¨Ò壺ÊǶÈΪ2µÄÓÐÐòÊ÷£¬ËüµÄÌصãÊÇÿ¸ö½ÚµãÖÁ¶àÓÐÁ½¿Ã×ÓÊ÷
* ÎÒÃǵÄËã·¨¾ÍÊǸù¾Ý¶þ²æÊ÷µÄµÝ¹é¶¨Òå¶øÀ´£¬ÏÂÃæÊǶþ²æÊ÷µÄµÝ¹é¶¨Ò壺
* n(n>=0)¸ö½ÚµãµÄÓÐÏÞ¼¯¡£Ëü ......
ÎļþÉÏ´«·½·¨£¨Ò»´ÎÉÏ´«Ò»¸öÎļþ£¬¶à¸öÎļþµÄ»°£¬Çëдѻ·µ÷Óã©
Upload.uploadFile(theFile, filePath)
˵Ã÷£º
theFile£ºÀàÐÍÊÇFormFile
filePath£ºactionÖз¾¶»ñÈ¡·½·¨ this.getServlet().getServletContext().getRealPath("/")
µ÷Óô˷½·¨·µ»ØÎļþÉÏ´«ºóµÄ·¾¶Ãû
ÉÏ´«¶à¸öÎļþʱ£¬ÇëÉèÖÃÿ¸öÎ ......