Java µÄping ·½·¨
import java.io.IOException;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.nio.channels.SelectionKey;
import java.nio.channels.Selector;
import java.nio.channels.SocketChannel;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.regex.Pattern;
public class Ping {
// The default daytime port
static int DAYTIME_PORT = 13;
// The port we'll actually use
static int port = DAYTIME_PORT;
private String host;
public String getHost() {
return host;
}
public void setHost(String host) {
this.host = host;
}
public void setPort(int port){
this.port = port;
}
// private String
// Representation of a ping target
//
static class Target {
InetSocketAddress address;
SocketChannel channel;
Exception failure;
long connectStart;
long connectFinish = 0;
boolean shown = false;
boolean pingResult = false;
Target(String host) {
try {
address = new InetSocketAddress(InetAddress.getByName(host), port);
} catch
Ïà¹ØÎĵµ£º
public static boolean telnetTest() {
boolean b=false;
Socket server = null;
try {
server = new Socket();
InetSocketAddress address = new InetSocketAddress(
"192.168.1.101", 80);
server.connect(address, 5000);
b=true;
} catch (UnknownHostException e) {
e.printSta ......
µÚÒ»ÖÖ:ЧÂʸß
Map map = new HashMap();
Iterator iter = map.entrySet().iterator();
while (iter.hasNext()) {
Map.Entry entry = (Map.Entry) iter.next();
Object key = entry.getKey();
Object val = entry.getValue();
}
µÚ¶þÖÖ:ЧÂʵÍ,ÒÔºó¾¡Á¿ÉÙʹÓã¡
Map map = new HashMap();
......
Ò». Êý×é
. ÕýÈ·µÄ¶¨Òå: int num[]; num= new int[5] //Ö»ÓÐÓÃnew¹Ø¼ü×ÖÕæÕý´´½¨Êý×éʱ²Å¿ÉÒÔ¸ø¶¨ËüµÄ´óС
´íÎóµÄ¶¨Òå: int num[5];
. ³£¼ûµÄÊý×é´íÎóΪ : ArrayIndexOutOfBoundsException (Êý×éÔ½½ç´íÎó)
. Êý×éµÄά¶ ......
import java.applet.*;
import java.awt.*;
import java.io.*;
import java.net.URL;
import java.util.*;
public class Typewriter4 extends Applet implements Runnable
{
AudioClip hit, cr, ding ;
boolean alreadyRun = false,
& ......
ÒÔǰÎÒÒ»Ö±ÒÔΪFile#renameTo(File)·½·¨ÓëOSÏÂÃæµÄ move/mv ÃüÁîÊÇÏàͬµÄ£¬¿ÉÒÔ´ïµ½¸ÄÃû¡¢Òƶ¯ÎļþµÄÄ¿µÄ¡£²»¹ýºóÀ´¾³£·¢ÏÖÎÊÌ⣺File#renameTo(File)·½·¨»á·µ»ØÊ§°Ü(false)£¬ÎļþûÓÐÒÆ¶¯£¬Óֲ鲻³öÔÒò£¬ÔÙºóÀ´¸É´àÆúÓø÷½·¨£¬×Ô¼ºÊµÏÖÒ»¸öcopy·½·¨£¬ÎÊÌâµ¹ÊÇÔÙҲûÓгöÏÖ¹ý¡£
×òÌìÀϰåͬѧÓÖÓöµ½Õâ¸öÎÊÌ⣬File#rena ......