HttpURLConnection이 연결의 입력 스트림을 유지하는 방법이 궁금합니다. 나는 부모 추상 클래스 URLConnection의의 구현을 확인하고 URLConnection의이 메소드를 오버라이드 (override) 나던 확장하는 방법HttpURLConnection에서 inputStream 인스턴스를 가져 오는 방법은 무엇입니까?
/**
* Returns an {@code InputStream} for reading data from the resource pointed by
* this {@code URLConnection}. It throws an UnknownServiceException by
* default. This method must be overridden by its subclasses.
*
* @return the InputStream to read data from.
* @throws IOException
* if no InputStream could be created.
*/
public InputStream getInputStream() throws IOException {
throw new UnknownServiceException("Does not support writing to the input stream");
}
HttpURLConnection의 발견. 그렇다면 입력 스트림 참조가 어떻게 얻어지는 지 궁금하십니까?
이와 관련된 문제 .... 정확히 http 요청이 클라이언트에서 서버로 이동합니까? getInputStream()을 호출 할 때입니까? 또는 openConnection()이 호출되자 마자? 사전 AK
에서
덕분에
Dev. java.net.HttpURLConnection을 사용하고 있으며 sun.net.www.protocol.http.HttpURLConnection의 인스턴스를 말한 것처럼 ....하지만 Java SDK에 포함 된 내용으로 보지 않습니다. 이것을 외부 항아리로 가져와야합니까? OpenJDK의 일부인 것을 알 수 있습니다. http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/6-b14/sun/net/www/protocol/http/HttpURLConnection.java – AKh
Java JDK에 포함되어 있습니다. rt.jar. – EJP
@AKh 구현은 항상 런타임 환경에서 제공됩니다. – Dev