java write interface test DEMO

---A random internet search

import java.io.IOException;

import java.io.InputStream;

import java.net.MalformedURLException;

import java.net.

import java.net.URL;

import java.net.URLConnection;

public class URLAccess {

public static void main(String[] args) {

try {

test();

} catch (MalformedURLException e) {

e.printStackTrace();

} catch (IOException e) {

e. printStackTrace();

}

}

public static void test() throws IOException {

URL url = new URL("");

System.out. println("================== following content for the website ==================");

URLConnection urlcon = url.openConnection();

int i = urlcon. getContentLength();

if (i > 0) {

InputStream is = urlcon.getInputStream();

int a;

while ((a = is.read()) ! = -1) {

System.out.print((char) a);

}

is.close();

} else {

System.out.println("Response is empty...") ;

}

}

}