Android Open Source - mycitybikes-android Utils






From Project

Back to project page mycitybikes-android.

License

The source code is released under:

GNU General Public License

If you think the Android project mycitybikes-android listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.mycitybikes.android.util;
//  w w w . j  a  v  a 2s .co m
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;

import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.params.BasicHttpParams;
import org.apache.http.params.HttpConnectionParams;
import org.apache.http.params.HttpParams;

public class Utils {

  public static String parseISToString(java.io.InputStream is)
      throws IOException {
    BufferedReader reader = new BufferedReader(new InputStreamReader(is,
        "UTF-8"));
    StringBuilder sb = new StringBuilder();
    try {
      String line = null;
      while ((line = reader.readLine()) != null) {
        sb.append(line).append("\n");
      }
    } finally {
      try {
        is.close();
      } catch (Exception ex) {
      }
      try {
        reader.close();
      } catch (Exception ex) {
      }
    }
    return sb.toString();
  }

  public static InputStream readContent(String httpUrl, int timeout) {
    try {
      HttpParams params = new BasicHttpParams();
      HttpConnectionParams.setConnectionTimeout(params, timeout);
      HttpClient httpclient = new DefaultHttpClient(params);
  
      HttpGet httpGet = new HttpGet(httpUrl);
      HttpResponse response = httpclient.execute(httpGet);
      return response.getEntity().getContent();
    } catch (Exception e) {
      throw new RuntimeException(
          "Unable to read content from " + httpUrl, e);
    }
  }

}




Java Source Code List

com.mycitybikes.android.ClearChannel.java
com.mycitybikes.android.Constants.java
com.mycitybikes.android.JCDecaux.java
com.mycitybikes.android.MyCityBikesActivity.java
com.mycitybikes.android.model.City.java
com.mycitybikes.android.model.StationInfoBuilder.java
com.mycitybikes.android.model.StationLocation.java
com.mycitybikes.android.model.StationStatus.java
com.mycitybikes.android.util.AndroidUtils.java
com.mycitybikes.android.util.Utils.java
com.mycitybikes.android.view.MapLocationItemizedOverlay.java