package primer11; import java.net.*; import java.io.*; import java.util.*; public class Weblog { public static void main(String[] args) { Date start = new Date(); try (BufferedReader bin = new BufferedReader(new InputStreamReader(new FileInputStream(args[0])));) { String entry = null; while ((entry = bin.readLine()) != null) { int index = entry.indexOf(' '); String ip = entry.substring(0, index); String theRest = entry.substring(index); try { InetAddress address = InetAddress.getByName(ip); System.out.println(address.getHostName() + theRest); } catch (UnknownHostException ex) { System.out.println(entry); } } } catch (IOException ex) { System.out.println("Exception: " + ex); } Date end = new Date(); double elapsedTime = (end.getTime() - start.getTime()) / 1000.0; System.out.println("Elapsed time: " + elapsedTime + " seconds"); } }