-
Notifications
You must be signed in to change notification settings - Fork 0
/
HttpRequest.java
28 lines (24 loc) · 989 Bytes
/
HttpRequest.java
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
package su.selezzz.storytools.procedures;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
public class HttpRequest {
public static String getToken(String token) throws IOException {
final URL url = new URL("https://selezzzdev.pythonanywhere.com/get2/" + token);
final HttpURLConnection con = (HttpURLConnection) url.openConnection();
con.setRequestMethod("GET");
try (final BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()))) {
final StringBuilder content = new StringBuilder();
String inputLine;
while ((inputLine = in.readLine()) != null) {
content.append(inputLine);
}
return content.toString();
} catch (final Exception ex) {
ex.printStackTrace();
return "";
}
}
}