Java Code Examples for java.net.HttpURLConnection.getInputStream()

The following are Jave code examples for showing how to use getInputStream() of the java.net.HttpURLConnection class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: Clases-2017c1   File: UrlRequest.java   View Source Code Vote up 8 votes
@Override
public void run() {
    try {
        HttpURLConnection connection = (HttpURLConnection) url.openConnection();
        InputStream stream = connection.getInputStream();
        int responseCode = connection.getResponseCode();
        ByteArrayOutputStream responseBody = new ByteArrayOutputStream();
        byte buffer[] = new byte[1024];
        int bytesRead = 0;
        while ((bytesRead = stream.read(buffer)) > 0) {
            responseBody.write(buffer, 0, bytesRead);
        }
        listener.onReceivedBody(responseCode, responseBody.toByteArray());
    }
    catch (Exception e) {
        listener.onError(e);
    }
}
 
Example 2
Project: JOsu   File: StringUtils.java   View Source Code Vote up 8 votes
public static String getStringFromWebsite(URL url) throws MalformedURLException, IOException{
	StringBuilder stringBuilder = new StringBuilder();
	HttpURLConnection conn = (HttpURLConnection) url.openConnection();
	conn.setDoOutput(true);
	conn.setRequestProperty("User-Agent", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.155 Safari/537.36");
	conn.setRequestProperty("X-HTTP-Method-Override", "GET");
	conn.setRequestProperty("Accept-Charset", "UTF-8");
	conn.setRequestProperty("Content-Type", "text/plain; charset=utf-8");
	BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream(), Charset.forName("UTF-8")));
	String inputLine;
	while ((inputLine = in.readLine()) != null) {
		stringBuilder.append(inputLine);
	}
	in.close();
	return stringBuilder.toString();
}
 
Example 3
Project: GitHub   File: RealmVersionChecker.java   View Source Code Vote up 7 votes
private String checkLatestVersion() {
    String result = REALM_VERSION;
    try {
        URL url = new URL(VERSION_URL + REALM_VERSION);
        HttpURLConnection conn = (HttpURLConnection) url.openConnection();
        conn.setConnectTimeout(CONNECT_TIMEOUT);
        conn.setReadTimeout(READ_TIMEOUT);
        BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
        String latestVersion = rd.readLine();
        // if the obtained string does not match the pattern, we are in a separate network.
        if (latestVersion.matches(REALM_VERSION_PATTERN)) {
            result = latestVersion;
        }
        rd.close();
    } catch (IOException e) {
        // We ignore this exception on purpose not to break the build system if this class fails
    }
    return result;
}
 
Example 4
Project: android-dev-challenge   File: NetworkUtils.java   View Source Code Vote up 6 votes
/**
 * This method returns the entire result from the HTTP response.
 *
 * @param url The URL to fetch the HTTP response from.
 * @return The contents of the HTTP response.
 * @throws IOException Related to network and stream reading
 */
public static String getResponseFromHttpUrl(URL url) throws IOException {
    HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
    try {
        InputStream in = urlConnection.getInputStream();

        Scanner scanner = new Scanner(in);
        scanner.useDelimiter("\\A");

        boolean hasInput = scanner.hasNext();
        if (hasInput) {
            return scanner.next();
        } else {
            return null;
        }
    } finally {
        urlConnection.disconnect();
    }
}
 
Example 5
Project: pScrobbler   File: Scrobbler.java   View Source Code Vote up 6 votes
/**
 * Internally performs the handshake operation by calling the given <code>url</code> and examining the response.
 *
 * @param url The URL to call
 * @return the status of the operation
 * @throws IOException on I/O errors
 */
private ResponseStatus performHandshake(String url) throws IOException {
	HttpURLConnection connection = Caller.getInstance().openConnection(url);
	InputStream is = connection.getInputStream();
	BufferedReader r = new BufferedReader(new InputStreamReader(is));
	String status = r.readLine();
	int statusCode = ResponseStatus.codeForStatus(status);
	ResponseStatus responseStatus;
	if (statusCode == ResponseStatus.OK) {
		this.sessionId = r.readLine();
		this.nowPlayingUrl = r.readLine();
		this.submissionUrl = r.readLine();
		responseStatus = new ResponseStatus(statusCode);
	} else if (statusCode == ResponseStatus.FAILED) {
		responseStatus = new ResponseStatus(statusCode, status.substring(status.indexOf(' ') + 1));
	} else {
		return new ResponseStatus(statusCode);
	}
	r.close();
	return responseStatus;
}
 
Example 6
Project: android-dev-challenge   File: NetworkUtils.java   View Source Code Vote up 6 votes
/**
 * This method returns the entire result from the HTTP response.
 *
 * @param url The URL to fetch the HTTP response from.
 * @return The contents of the HTTP response.
 * @throws IOException Related to network and stream reading
 */
public static String getResponseFromHttpUrl(URL url) throws IOException {
    HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
    try {
        InputStream in = urlConnection.getInputStream();

        Scanner scanner = new Scanner(in);
        scanner.useDelimiter("\\A");

        boolean hasInput = scanner.hasNext();
        if (hasInput) {
            return scanner.next();
        } else {
            return null;
        }
    } finally {
        urlConnection.disconnect();
    }
}
 
Example 7
Project: Stitch   File: MainActivity.java   View Source Code Vote up 6 votes
public static Bitmap getBitmapFromURL(String src) {
    try {
        URL url = new URL(src);
        HttpURLConnection connection = (HttpURLConnection) url.openConnection();
        connection.setDoInput(true);
        connection.connect();
        InputStream input = connection.getInputStream();
        return BitmapFactory.decodeStream(input);
    } catch (IOException e) {
        // Log exception
        return null;
    }
}
 
Example 8
Project: chromium-net-for-android   File: CronetFixedModeOutputStreamTest.java   View Source Code Vote up 5 votes
@SmallTest
@Feature({"Cronet"})
@CompareDefaultWithCronet
public void testWriteMoreThanContentLengthWriteOneByte()
        throws Exception {
    URL url = new URL(NativeTestServer.getEchoBodyURL());
    HttpURLConnection connection =
            (HttpURLConnection) url.openConnection();
    connection.setDoOutput(true);
    connection.setRequestMethod("POST");
    // Set a content length that's 1 byte short.
    connection.setFixedLengthStreamingMode(TestUtil.UPLOAD_DATA.length - 1);
    OutputStream out = connection.getOutputStream();
    for (int i = 0; i < TestUtil.UPLOAD_DATA.length - 1; i++) {
        out.write(TestUtil.UPLOAD_DATA[i]);
    }
    try {
        // Try upload an extra byte.
        out.write(TestUtil.UPLOAD_DATA[TestUtil.UPLOAD_DATA.length - 1]);
        // On Lollipop, default implementation only triggers the error when reading response.
        connection.getInputStream();
        fail();
    } catch (ProtocolException e) {
        // Expected.
        String expectedVariant = "expected 0 bytes but received 1";
        String expectedVariantOnLollipop = "expected " + (TestUtil.UPLOAD_DATA.length - 1)
                + " bytes but received " + TestUtil.UPLOAD_DATA.length;
        assertTrue(expectedVariant.equals(e.getMessage())
                || expectedVariantOnLollipop.equals(e.getMessage()));
    }
    connection.disconnect();
}
 
Example 9
Project: flume-release-1.7.0   File: TestHTTPMetricsServer.java   View Source Code Vote up 5 votes
private void testWithPort(int port) throws Exception {
  MonitorService srv = new HTTPMetricsServer();
  Context context = new Context();
  if (port > 1024) {
    context.put(HTTPMetricsServer.CONFIG_PORT, String.valueOf(port));
  } else {
    port = HTTPMetricsServer.DEFAULT_PORT;
  }
  srv.configure(context);
  srv.start();
  Thread.sleep(1000);
  URL url = new URL("http://0.0.0.0:" + String.valueOf(port) + "/metrics");
  HttpURLConnection conn = (HttpURLConnection) url.openConnection();
  conn.setRequestMethod("GET");
  BufferedReader reader = new BufferedReader(
          new InputStreamReader(conn.getInputStream()));
  String line;
  String result = "";
  while ((line = reader.readLine()) != null) {
    result += line;
  }
  reader.close();
  Map<String, Map<String, String>> mbeans = gson.fromJson(result, mapType);
  Assert.assertNotNull(mbeans);
  Map<String, String> memBean = mbeans.get("CHANNEL.memChannel");
  Assert.assertNotNull(memBean);
  JMXTestUtils.checkChannelCounterParams(memBean);
  Map<String, String> pmemBean = mbeans.get("CHANNEL.pmemChannel");
  Assert.assertNotNull(pmemBean);
  JMXTestUtils.checkChannelCounterParams(pmemBean);
  srv.stop();
  System.out.println(String.valueOf(port) + "test success!");
}
 
Example 10
Project: azure-spring-boot   File: AzureADGraphClient.java   View Source Code Vote up 5 votes
private static String getResponseStringFromConn(HttpURLConnection conn) throws IOException {

        try (BufferedReader reader = new BufferedReader(
                new InputStreamReader(conn.getInputStream(), StandardCharsets.UTF_8))) {
            final StringBuilder stringBuffer = new StringBuilder();
            String line = "";
            while ((line = reader.readLine()) != null) {
                stringBuffer.append(line);
            }
            return stringBuffer.toString();
        }
    }
 
Example 11
Project: bubichain-sdk-java   File: HttpKit.java   View Source Code Vote up 5 votes
/**
 * 鍙戦�丟et璇锋眰
 * @param url
 * @return
 * @throws NoSuchProviderException 
 * @throws NoSuchAlgorithmException 
 * @throws IOException 
 * @throws KeyManagementException 
 */
public static String get(String url) throws NoSuchAlgorithmException, NoSuchProviderException, IOException, KeyManagementException {
	if(enableSSL){
		return get(url,true);
	}else{
		StringBuffer bufferRes = null;
        URL urlGet = new URL(url);
        HttpURLConnection http = (HttpURLConnection) urlGet.openConnection();
        // 杩炴帴瓒呮椂
        http.setConnectTimeout(25000);
        // 璇诲彇瓒呮椂 --鏈嶅姟鍣ㄥ搷搴旀瘮杈冩參锛屽澶ф椂闂�
        http.setReadTimeout(25000);
        http.setRequestMethod("GET");
        http.setRequestProperty("Content-Type","application/x-www-form-urlencoded");
        http.setDoOutput(true);
        http.setDoInput(true);
        http.connect();
        
        InputStream in = http.getInputStream();
        BufferedReader read = new BufferedReader(new InputStreamReader(in, DEFAULT_CHARSET));
        String valueString = null;
        bufferRes = new StringBuffer();
        while ((valueString = read.readLine()) != null){
            bufferRes.append(valueString);
        }
        in.close();
        if (http != null) {
            // 鍏抽棴杩炴帴
            http.disconnect();
        }
        return bufferRes.toString();
	}
}
 
Example 12
Project: apache-tomcat-7.0.73-with-comment   File: TestRequest.java   View Source Code Vote up 5 votes
@Test
public void testBug49424NoChunking() throws Exception {
    Tomcat tomcat = getTomcatInstance();
    // No file system docBase required
    Context root = tomcat.addContext("", null);
    Tomcat.addServlet(root, "Bug37794", new Bug37794Servlet());
    root.addServletMapping("/", "Bug37794");
    tomcat.start();

    HttpURLConnection conn = getConnection("http://localhost:" + getPort() + "/");
    InputStream is = conn.getInputStream();
    assertNotNull(is);
}
 
Example 13
Project: Exoplayer2Radio   File: IcyDataSource.java   View Source Code Vote up 5 votes
@Override
protected InputStream getInputStream(HttpURLConnection conn) throws Exception {
    // Get the input stream from the connection. Actually returns the underlying stream or IcyInputStream
    String smetaint = conn.getHeaderField( "icy-metaint");
    InputStream ret = conn.getInputStream();

    if (!metadataEnabled) {
        LogHelper.v(LOG_TAG, "Metadata not enabled");
    }
    else if (smetaint != null) {
        int period = -1;
        try {
            period = Integer.parseInt( smetaint);
        }
        catch (Exception e) {
            LogHelper.e(LOG_TAG, "The icy-metaint '" + smetaint + "' cannot be parsed: '" + e);
        }

        if (period > 0) {
            LogHelper.v(LOG_TAG, "The dynamic metainfo is sent every " + period + " bytes");

            ret = new IcyInputStream(ret, period, playerCallback, null);
        }
    }
    else LogHelper.v(LOG_TAG, "This stream does not provide dynamic metainfo");

    return ret;
}
 
Example 14
Project: RDF2PT   File: Gtranslate.java   View Source Code Vote up 5 votes
public String callUrlAndParseResult(String langFrom, String langTo,
                                            String word) throws Exception 
{

 String url = "https://translate.googleapis.com/translate_a/single?"+
   "client=gtx&"+
   "sl=" + langFrom + 
   "&tl=" + langTo + 
   "&dt=t&q=" + URLEncoder.encode(word, "UTF-8");    
 
 URL obj = new URL(url);
 HttpURLConnection con = (HttpURLConnection) obj.openConnection(); 
 con.setRequestProperty("User-Agent", "Mozilla/5.0");

 BufferedReader in = new BufferedReader(
   new InputStreamReader(con.getInputStream()));
 String inputLine;
 StringBuffer response = new StringBuffer();

 while ((inputLine = in.readLine()) != null) {
  response.append(inputLine);
 }
 in.close();

 
 String result = parseResult(response.toString());
 
 if(result.equals("")){
  return word;
 } else {
 return result;}
 
 
}
 
Example 15
Project: NetCompile   File: FileHelper.java   View Source Code Vote up 5 votes
public static String[] uploadEditorContent(TestSceneController controller) throws Exception
{
   String url = "http://danieloluwadare.com/write.php";
   url = "http://ec2-52-14-237-83.us-east-2.compute.amazonaws.com/write.php";
   //local
   url = "http://localhost/danielOluwadare.com/write.php";
   
   String charset = java.nio.charset.StandardCharsets.UTF_8.name();

   HttpURLConnection connection = (HttpURLConnection)new URL(url).openConnection();
   /*********************/
   /*
   school = "neiu";
   dept = "304-17";
   semester = "spr2017";
   test = "midterm";
   studentId = "265456";      
   */      

   String content = controller.getCode();
   String newContent = "";
   for( int i=0; i<content.length(); i++ ) 
   {
      if( content.charAt(i) == '+' ) 
         newContent += "%2B";
      else if( content.charAt(i) == '\t')
          newContent += "    ";
      else
         newContent += content.charAt(i);
   }

   String urlParameters  = "classID=" + controller.getCourse() + "&semester=" + controller.getSemester() + 
                  "&testDesc=" + controller.getTest() + "&studentID=" + controller.getStudentId() + 
                  "&school=" + controller.getSchool() + "&fileName=" + controller.getProblemName() + 
                  "&content=" + newContent;
   byte[] postData       = urlParameters.getBytes( java.nio.charset.StandardCharsets.UTF_8 );
   int    postDataLength = postData.length;
   String request        = url;
   URL    url2            = new URL( request );
   HttpURLConnection conn= (HttpURLConnection) url2.openConnection();           
   conn.setDoOutput( true );
   conn.setInstanceFollowRedirects( false );
   conn.setRequestMethod( "POST" );
   conn.setRequestProperty( "Content-Type", "application/x-www-form-urlencoded"); 
   conn.setRequestProperty( "charset", "utf-8");
   conn.setRequestProperty( "Content-Length", Integer.toString( postDataLength ));
   conn.setUseCaches( false );
   try( DataOutputStream wr = new DataOutputStream( conn.getOutputStream())) {
      wr.write( postData );
   }
   
   StringBuilder sb = new StringBuilder();  
   int HttpResult = conn.getResponseCode(); 
   if (HttpResult == HttpURLConnection.HTTP_OK) 
   {
      BufferedReader br = new BufferedReader(
         new InputStreamReader(conn.getInputStream(), "utf-8"));
      String line = null;  
      while ((line = br.readLine()) != null) 
      {  
         sb.append(line);  
      }
      br.close();
         
      String res = sb.toString();
      System.out.println(res);  

      res = res.replaceAll("\\[", "").replaceAll("\\]","");
      String[] retList = res.split(",", -1);
      
      return retList;
   }
   else 
   {
      System.out.println(conn.getResponseMessage());  
      return new String[0];
   }        
}
 
Example 16
Project: react-native-save-image   File: SaveImageModule.java   View Source Code Vote up 5 votes
private  InputStream getImageStream(String filePath) throws Exception{
    URL url = new URL(filePath);
    HttpURLConnection conn = (HttpURLConnection) url.openConnection();
    conn.setConnectTimeout(5 * 1000);
    conn.setRequestMethod("GET");
    if(conn.getResponseCode() == HttpURLConnection.HTTP_OK){
        return conn.getInputStream();
    }
    return null;
}
 
Example 17
Project: JWebAssembly   File: SpiderMonkey.java   View Source Code Vote up 4 votes
/**
 * Check if there is a new version of the script engine
 * 
 * @throws IOException
 *             if any error occur
 */
private void download() throws IOException {
    boolean is32 = "32".equals( System.getProperty( "sun.arch.data.model" ) );
    String fileName;
    final String os = System.getProperty( "os.name", "" ).toLowerCase();
    if( os.contains( "windows" ) ) {
        fileName = is32 ? "win32" : "win64";
    } else if( os.contains( "mac" ) ) {
        fileName = is32 ? "mac" : "mac64";
    } else if( os.contains( "linux" ) ) {
        fileName = is32 ? "linux-i686" : "linux-x86_64";
    } else {
        throw new IllegalStateException( "Unknown OS: " + os );
    }
    File target = new File( System.getProperty( "java.io.tmpdir" ) + "/SpiderMonkey" );
    URL url = new URL( "https://archive.mozilla.org/pub/firefox/nightly/latest-mozilla-central/jsshell-" + fileName
                    + ".zip" );
    System.out.println( "\tDownload: " + url );
    HttpURLConnection conn = (HttpURLConnection)url.openConnection();
    if( target.exists() ) {
        System.out.println( "\tUP-TP-DATE" );
        conn.setIfModifiedSince( target.lastModified() );
    }
    InputStream input = conn.getInputStream();
    command = target.getAbsolutePath() + "/js";
    if( conn.getResponseCode() == HttpURLConnection.HTTP_NOT_MODIFIED ) {
        return;
    }
    ZipInputStream zip = new ZipInputStream( input );
    long lastModfied = conn.getLastModified();
    do {
        ZipEntry entry = zip.getNextEntry();
        if( entry == null ) {
            break;
        }
        if( entry.isDirectory() ) {
            continue;
        }
        File file = new File( target, entry.getName() );
        file.getParentFile().mkdirs();

        Files.copy( zip, file.toPath(), StandardCopyOption.REPLACE_EXISTING );
        file.setLastModified( entry.getTime() );
        if( "js".equals( file.getName() ) ) {
            file.setExecutable( true );
        }
    } while( true );
    target.setLastModified( lastModfied );
}
 
Example 18
Project: MMDownloader   File: SystemInfo.java   View Source Code Vote up 4 votes
/**
 * <p>최신버전 다운로드 메서드.
 * <p>최신버전 확인 메서드 내부에서 불러지는 용도로만 사용하게 제한.
 * <p>사용자의 OS 값에 따라서 윈도우 / 그 이외(맥, 리눅스) 버전을 다운로드
 * @param in 키보드 입력용 버퍼리더 객체
 */
private static void downloadLatestVersion(final BufferedReader in){
	try{
		final int BUF_SIZE = 10485760;
		//다운받은 바이트 길이, MB로 나누기 위한 값, 직전 다운로드 MB 값
		int len = 0, MB = 1024*1024, preDownloadedMB = 0;
		double accumSize = 0, totalSize = 0;//누적 다운로드 바이트, 총 파일 크기 바이트
		
		String select, fileName = null, fileURL = null;
		boolean isCorrectlySelected = false;
		
		while(!isCorrectlySelected){ //다운로드 받거나(y) 취소(n)를 제대로 선택할 때 까지 반복.
			System.out.printf("최신 버전(%s)을 다운받으시겠습니까? (Y/n): ", LATEST_VERSION);
			select = in.readLine();
			
			if(select.equalsIgnoreCase("y")){
				isCorrectlySelected = true;
				makeDir(); //Marumaru폴더 생성
				
				/* OS가 윈도우면, 파일 이름 = MMdownloader_0.5.0.0_Windows.zip */
				if(OS_NAME.contains("Windows")){
					fileName = LATEST_WINDOWS.substring(LATEST_WINDOWS.lastIndexOf("/")+1);
					fileURL = LATEST_WINDOWS;
				}
				/* OS가 윈도우 이외면 파일 이름 = MMdownloader_0.5.0.0_Mac,Linux.zip */
				else{
					fileName = LATEST_OTHERS.substring(LATEST_OTHERS.lastIndexOf("/")+1);
					fileURL = LATEST_OTHERS;
				}
				
				System.out.println("다운로드중 ...");
				System.out.println("저장 위치: "+DEFAULT_PATH+fileSeparator+fileName);
				
				BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(DEFAULT_PATH+fileSeparator+fileName), BUF_SIZE);
				HttpURLConnection conn = (HttpURLConnection)new URL(fileURL).openConnection();
				conn.setConnectTimeout(60000); // 타임아웃 1분 요청
				BufferedInputStream bis = new BufferedInputStream(conn.getInputStream(), BUF_SIZE);
				
				totalSize = (double)conn.getContentLength() / MB; //KB
				
				while((len = bis.read()) != -1){
					bos.write(len);
					accumSize += (double)len / MB;
					
					if(preDownloadedMB < (int)accumSize){ //MB단위로만 로그 출력
						System.out.printf("%5.2fMB / %5.2fMB ... 완료!\n", accumSize, totalSize);
						preDownloadedMB = (int)accumSize;
					}
				}
				bos.close();
				bis.close();
				
				//마지막 로그 출력
				System.out.printf("%5.2fMB / %5.2fMB ... 완료!\n", accumSize, totalSize);
				System.out.println("최신버전 다운로드 완료! (위치: "+SystemInfo.DEFAULT_PATH+")");
			}
			else if(select.equalsIgnoreCase("n")){
				isCorrectlySelected = true;
				System.out.println("업데이트가 취소되었습니다.");
			}
		}
	}
	catch(Exception e){
		ErrorHandling.saveErrLog("최신버전 다운로드 에러", "", e);
	}
}
 
Example 19
Project: appinventor-extensions   File: Texting.java   View Source Code Vote up 4 votes
/**
 * Free software method copied and adapted from Voice.java
 * @see http://code.google.com/p/google-voice-java/
 * 
 */
private String sendGvSms(String smsData) {
  Log.i(TAG, "sendGvSms()");
  StringBuilder response = new StringBuilder();
  try {
    // Add the RNR_SE to the message
    smsData += "&" + URLEncoder.encode("_rnr_se", UTF8) + "=" + URLEncoder.encode(rnrSEE, UTF8);
    Log.i(TAG, "smsData = " + smsData);
    URL smsUrl = new URL(GV_SMS_SEND_URL);

    HttpURLConnection smsConn = (HttpURLConnection) smsUrl.openConnection();
    smsConn.setRequestProperty( "Authorization", "GoogleLogin auth=" + authToken );
    smsConn.setRequestProperty("User-agent", USER_AGENT);
    setCookies(smsConn);
    smsConn.setDoOutput(true);
    smsConn.setConnectTimeout(SERVER_TIMEOUT_MS);

    Log.i(TAG, "sms request = " + smsConn);
    OutputStreamWriter callwr = new OutputStreamWriter(smsConn.getOutputStream());
    callwr.write(smsData);
    callwr.flush();

    processCookies(smsConn);
    BufferedReader callrd = new BufferedReader(new InputStreamReader(smsConn.getInputStream()));

    String line;
    while ((line = callrd.readLine()) != null) {
      response.append(line);
      response.append("\n");  // HTTP uses \r\n, but Android is built on Linux, so use Unix line endings
    }
    Log.i(TAG, "sendGvSms:  Sent SMS, response = " + response);

    callwr.close();
    callrd.close();

    if (response.length() == 0) {
      throw new IOException("No Response Data Received.");
    } else {
      return response.toString();
    }
  } catch (IOException e) {
    Log.i(TAG, "IO Error on Send " + e.getMessage(), e);
    return "IO Error Message not sent";
  }
}
 
Example 20
Project: xxpay-master   File: HttpClient.java   View Source Code Vote up 3 votes
/**
 * 以http get方式通信
 *
 * @param url
 * @throws IOException
 */
protected void httpGetMethod(String url) throws IOException {

    HttpURLConnection httpConnection =
            HttpClientUtil.getHttpURLConnection(url);

    this.setHttpRequest(httpConnection);

    httpConnection.setRequestMethod("GET");

    this.responseCode = httpConnection.getResponseCode();

    this.inputStream = httpConnection.getInputStream();

}