package Tech;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
public class GetHtmlFile {
/**
* @param args
* @throws IOException
* @throws URISyntaxException
*/
public static void main(String[] args) throws IOException, URISyntaxException {
// TODO Auto-generated method stub
URL url= new URL("http://www.163.com");
InputStream is = url.openStream();
//OutputStream ois= url.openConnection().getOutputStream();
File file = new File(new URI("file:/c:/g3.txt"));
FileOutputStream fos = new FileOutputStream(file);
BufferedOutputStream bos = new BufferedOutputStream(fos);
int ch;
while((ch=is.read())!=-1)
{
bos.write(ch);
bos.flush();
//System.out.print((char)ch);
}
}
}