import java.net.URL; import java.net.URLConnection; import java.util.Date; public class dailyCode { public static void main(String[] args) { try{ URL url = new URL("http://www.google.com"); URLConnection conn = url.openConnection(); conn.connect();
System.out.println("ContentType : " + conn.getContentType()); System.out.println("ContentLength : " + conn.getContentLength() + " bytes"); System.out.println("LastModified : " + new Date(conn.getLastModified())); System.out.println("getDate : " + new Date(conn.getDate())); System.out.println("systemDate : " + new Date());
URL img = new URL("http://www.google.com/images/sunny.gif"); URLConnection connImg = img.openConnection(); connImg.connect(); System.out.println("\nContentType : " + connImg.getContentType()); System.out.println("ContentLength : " + connImg.getContentLength() + " bytes"); System.out.println("LastModified : " + new Date(connImg.getLastModified())); System.out.println("getDate : " + new Date(connImg.getDate())); System.out.println("systemDate : " + new Date());
}catch(Exception e){ e.printStackTrace(); } } } |
'프로그래밍 > JAVA' 카테고리의 다른 글
DatagramSocket Example (0) | 2016.12.03 |
---|---|
Implement Stack (0) | 2016.12.01 |
LinkedList Implementation (0) | 2016.11.29 |
URL class Example (0) | 2016.11.27 |
Find Google IP (InetAddress class Example) (0) | 2016.11.25 |
람다 표현식 (Lambda Expression) (0) | 2016.11.24 |
Arrays class Example (0) | 2016.11.23 |