package URL;
import java.io.BufferedInputStream;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.net.URL;
import java.net.URLConnection;
import java.util.Date;
public class openConnection {
public static void main(String[] args)throws Exception{
Date today=new Date();
long millisecondsPerDay=24*60*60*1000;
URL u=new URL("http://www.google.com");
URLConnection uc=u.openConnection();
uc.setIfModifiedSince((new Date(today.getTime() - millisecondsPerDay)).getTime());
InputStream in=new BufferedInputStream(uc.getInputStream());
Reader r=new InputStreamReader(in);
int c;
while((c=r.read())!=-1){
System.out.println((char)c);
}
}
}
'Java' 카테고리의 다른 글
Runtime : availableProcessors() (0) | 2015.01.28 |
---|---|
URL : openStream() (0) | 2015.01.25 |
URL : getAuthority() (0) | 2015.01.25 |
new URL(String spec) throws MalformedURLException (0) | 2015.01.25 |
InetAddress : isReacheable(int timeout) (0) | 2015.01.25 |