|
@@ -41,12 +41,7 @@ import java.util.Map;
|
41
|
41
|
/**
|
42
|
42
|
* Allows easy downloading of files from HTTP sites.
|
43
|
43
|
*/
|
44
|
|
-public final class Downloader {
|
45
|
|
-
|
46
|
|
- /** Creates a new instance of Downloader. */
|
47
|
|
- private Downloader() {
|
48
|
|
- // Shouldn't be used
|
49
|
|
- }
|
|
44
|
+public class Downloader {
|
50
|
45
|
|
51
|
46
|
/**
|
52
|
47
|
* Retrieves the specified page.
|
|
@@ -55,7 +50,7 @@ public final class Downloader {
|
55
|
50
|
* @return A list of lines received from the server
|
56
|
51
|
* @throws java.io.IOException If there's an I/O error while downloading
|
57
|
52
|
*/
|
58
|
|
- public static List<String> getPage(final String url) throws IOException {
|
|
53
|
+ public List<String> getPage(final String url) throws IOException {
|
59
|
54
|
|
60
|
55
|
return getPage(url, "");
|
61
|
56
|
}
|
|
@@ -68,7 +63,7 @@ public final class Downloader {
|
68
|
63
|
* @return A list of lines received from the server
|
69
|
64
|
* @throws java.io.IOException If there's an I/O error while downloading
|
70
|
65
|
*/
|
71
|
|
- public static List<String> getPage(final String url, final String postData)
|
|
66
|
+ public List<String> getPage(final String url, final String postData)
|
72
|
67
|
throws IOException {
|
73
|
68
|
|
74
|
69
|
final List<String> res = new ArrayList<>();
|
|
@@ -105,7 +100,7 @@ public final class Downloader {
|
105
|
100
|
* @return A list of lines received from the server
|
106
|
101
|
* @throws java.io.IOException If there's an I/O error while downloading
|
107
|
102
|
*/
|
108
|
|
- public static List<String> getPage(final String url,
|
|
103
|
+ public List<String> getPage(final String url,
|
109
|
104
|
final Map<String, String> postData) throws IOException {
|
110
|
105
|
final StringBuilder data = new StringBuilder();
|
111
|
106
|
|
|
@@ -126,7 +121,7 @@ public final class Downloader {
|
126
|
121
|
* @param file The file to save the page to
|
127
|
122
|
* @throws java.io.IOException If there's an I/O error while downloading
|
128
|
123
|
*/
|
129
|
|
- public static void downloadPage(final String url, final String file)
|
|
124
|
+ public void downloadPage(final String url, final String file)
|
130
|
125
|
throws IOException {
|
131
|
126
|
downloadPage(url, file, null);
|
132
|
127
|
}
|
|
@@ -139,7 +134,7 @@ public final class Downloader {
|
139
|
134
|
* @param listener The progress listener for this download
|
140
|
135
|
* @throws java.io.IOException If there's an I/O error while downloading
|
141
|
136
|
*/
|
142
|
|
- public static void downloadPage(final String url, final String file,
|
|
137
|
+ public void downloadPage(final String url, final String file,
|
143
|
138
|
final DownloadListener listener) throws IOException {
|
144
|
139
|
|
145
|
140
|
final URLConnection urlConn = getConnection(url, "");
|
|
@@ -189,7 +184,7 @@ public final class Downloader {
|
189
|
184
|
* @throws java.net.MalformedURLException If the specified URL is malformed
|
190
|
185
|
* @throws java.io.IOException If an I/O exception occurs while connecting
|
191
|
186
|
*/
|
192
|
|
- private static URLConnection getConnection(final String url,
|
|
187
|
+ private URLConnection getConnection(final String url,
|
193
|
188
|
final String postData)
|
194
|
189
|
throws MalformedURLException, IOException {
|
195
|
190
|
final URL myUrl = new URL(url);
|