CURL go Java HttpURLCconnection Ar Líne
Cuidíonn an uirlis seo leat cód ceangail Java HttpURLC a ghiniúint bunaithe ar Ordú CURL. Cóipeáil agus Greamaigh Ordú CURL agus Gin Java HttpURLCconnection.
Cad is féidir leat a dhéanamh le CURL go Java HttpURLCConnection Converter Online?
- CURL go Java Is uirlis an-uathúil é HttpURLCconnection chun ordú cURL a thiontú go Java HttpURLCConnection iarratas de Java HttpURLCconnection. An t-ionchur a sholáthraíonn ordú cURL an úsáideora chun Cód Ceangal Java HttpURLC a ghiniúint.
- Sábhálann an uirlis seo do chuid ama agus cabhraíonn sé le cód ceangail Java HttpURLC a ghiniúint gan stró.
- Oibríonn CURL go Java HttpURLCconnection go maith ar Windows, MAC, Linux, Chrome, Firefox, Edge agus Safari.
cad é CURL?
Is uirlis líne ordaithe foinse oscailte é cURL a íoslódálann comhaid ón ngréasán. Tacaíonn sé le héagsúlacht prótacail, lena n-áirítear Java HttpURLConnection, Java HttpURLConnectionS, FTP, SFTP, TFTP, Gopher agus daoine eile.
Conas CURL a thiontú go cód ceangail Java HttpURLC?
Step1: Greamaigh agus tiontaigh d’iarratais CURL go cód ceangail Java HttpURLC
Step2: Cóipeáil cód ceangail Java HttpURLC
Tiontaigh CURL mar shampla Java HttpURLCconnection
CURL
curl example.com
Cód Ceangail HttpURLC Java
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.Scanner;
class Main {
public static void main(String[] args) throws IOException {
URL url = new URL("http://example.com");
HttpURLConnection httpConn = (HttpURLConnection) url.openConnection();
httpConn.setRequestMethod("GET");
InputStream responseStream = httpConn.getResponseCode() / 100 == 2
? httpConn.getInputStream()
: httpConn.getErrorStream();
Scanner s = new Scanner(responseStream).useDelimiter("\\A");
String response = s.hasNext() ? s.next() : "";
System.out.println(response);
}
}