* @(#)DownloadPage.java
*
*
* @author Md. Saiful Islam
* @Reg : 2005331074
* @version 1.00 2010/7/29
*/
import java.awt.*;
import java.io.*;
import java.net.InetAddress;
import java.net.*;
import java.util.*;
import java.math.*;
import java.lang.*;
public class DownloadPage
{
public DownloadPage() { }
public static void main(String[] args) throws IOException
{
URL url;
InputStream is = null;
DataInputStream dis;
String Link,line,PageName;
Link = "http://www.facebook.com/";
FileOutputStream fileOutput;
PageName = "Download.html";
File file = new File(PageName);
file.createNewFile();
fileOutput = new FileOutputStream(file);
try
{
url = new URL(Link);
is = url.openStream();
dis = new DataInputStream(new BufferedInputStream(is));
while( ( line = dis.readLine() ) != null )
{
System.out.println(line);
fileOutput.write(line.getBytes());
}
}
catch ( MalformedURLException waste )
{
waste.printStackTrace();
}
catch ( IOException input )
{
input.printStackTrace();
}
finally
{
try
{
is.close();
}
catch (IOException ioe)
{
}
} // End of finally
} // End of main class
} // End of DownloadPage class
No comments:
Post a Comment