?? weblog.java
字號(hào):
//Weblog.java
import java.net.*;
import java.io.*;
import java.util.*;
import com.macfaq.io.SafeBufferedReader;
public class Weblog {
public static void main(String[] args) {
Date start = new Date( );
try {
//使用FileInputStream 類來(lái)裝飾輸入流
FileInputStream fin = new FileInputStream(args[0]);
Reader in = new InputStreamReader(fin);
SafeBufferedReader bin = new SafeBufferedReader(in);
String entry = null;
while ((entry = bin.readLine( )) != null) {
// 分離出IP地址
int index = entry.indexOf(' ', 0);
String ip = entry.substring(0, index);
String theRest = entry.substring(index, entry.length( ));
// 找到主機(jī)名字,并打印出來(lái)
try {
InetAddress address = InetAddress.getByName(ip);
System.out.println(address.getHostName( ) + theRest);
}
catch (UnknownHostException e) {
System.out.println(entry);
}
} // 循環(huán)終止
}
catch (IOException e) {
System.out.println("Exception: " + e);
}
Date end = new Date( );
long elapsedTime = (end.getTime()-start.getTime( ))/1000;
System.out.println("Elapsed time: " + elapsedTime + " seconds");
} // main終止
}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -