- Jun 6, 2020
- 11,559
- 4,422
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;
public class JavaDownloadWebPage2 {
public static void main(String args[]) throws IOException {
download("
}
public static void download(String urlString) throws IOException {
URL url = new URL(urlString);
try(
BufferedReader reader = new BufferedReader(new InputStreamReader(url.openStream()));
BufferedWriter writer = new BufferedWriter(new FileWriter("page.html"));
) {
String line;
while ((line = reader.readLine()) != null) {
writer.write(line);
}
System.out.println("Page downloaded.");
}
}
}
Java:
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;
public class JavaDownloadWebPage2 {
public static void main(String args[]) throws IOException {
download("
برای دیدن لینک ها باید ثبت نام کنید
");}
public static void download(String urlString) throws IOException {
URL url = new URL(urlString);
try(
BufferedReader reader = new BufferedReader(new InputStreamReader(url.openStream()));
BufferedWriter writer = new BufferedWriter(new FileWriter("page.html"));
) {
String line;
while ((line = reader.readLine()) != null) {
writer.write(line);
}
System.out.println("Page downloaded.");
}
}
}
Java:
برای دیدن لینک ها باید ثبت نام کنید