-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathManga.java
More file actions
58 lines (49 loc) · 1.51 KB
/
Manga.java
File metadata and controls
58 lines (49 loc) · 1.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package WebCrawler;
import java.io.FileOutputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.URL;
public class Manga{
public static String download(String website)
{
String result = "";
try {
URL url = new URL(website);
InputStream is = url.openStream(); // throws an IOException
BufferedReader br = new BufferedReader(new InputStreamReader(is));
String line = br.readLine();
while (line != null) {
result += line + "\n";
line = br.readLine();
}
} catch (IOException ioe) {
result = ioe.toString();
}
return result;
}
public static void main(String[] args){
//String url = "";
//String html = download(url);
String picLink = "https://mangadex.org/images/manga/21944.jpg?1524581221";
try
{
URL url = new URL(picLink);
InputStream is = url.openStream();
OutputStream os = new FileOutputStream("\\\\SD36\\JOHN\\StudentHome\\Kelvin.lai\\Desktop\\try");
byte[] b = new byte[2048];
int length;
while ((length = is.read(b)) != -1) {
os.write(b, 0, length);
}
is.close();
os.close();
}
catch(IOException e)
{
System.out.println(e);
}
}
}