Package Com.mkyong;Import Java.io.BufferedReader;Import Java.io.BufferedWriter;Import Java.io.File;Import Java.io.FileWriter;Import java.io.IOException;Import Java.io.InputStreamReader;Import java.net.MalformedURLException;Import Java.net.URL;Import java.net.URLConnection; Public classGeturlcontent{ Public Static voidMain(String[]Args) { URLUrl;Try {//Get URL contentUrl= New URL("Http://www.mkyong.com");URLConnectionConn=Url.OpenConnection();//Open the stream and put it into BufferedReaderBufferedReaderBr= New BufferedReader( New InputStreamReader(Conn.getInputStream()));StringInputline;//save to this filenameStringFileName= "/users/mkyong/test.html";FileFile= New File(FileName);if (!File.exists()) {File.CreateNewFile();}//use FileWriter to write fileFileWriterFw= New FileWriter(File.Getabsolutefile());BufferedWriterBw= New BufferedWriter(Fw); while ((Inputline=Br.ReadLine()) != NULL) {Bw.Write(Inputline);}Bw.Close();Br.Close();System. out.println("Done");} Catch (malformedurlexceptionE) {E.Printstacktrace();} Catch (IOExceptionE) {E.Printstacktrace();}}}