Android Open Source - binghamton_svc Get Membership Info






From Project

Back to project page binghamton_svc.

License

The source code is released under:

MIT License

If you think the Android project binghamton_svc 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 Parsers;
//w w w  .  j  a v  a2s.  c  om
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.URI;

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;

/**
 * Interacts with a specific website to parse for data about membership.
 * @author Christopher Zhang
 */
public class GetMembershipInfo 
{
  public String getInternetData() throws Exception
  {
    BufferedReader in = null;
    String data = null;
    try
    {
      HttpClient client = new DefaultHttpClient();
      URI website = new URI("http://www.busvc.blogspot.com/p/about.html");
      HttpGet request = new HttpGet();
      request.setURI(website);
      HttpResponse response = client.execute(request);
      in = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
      StringBuffer sb = new StringBuffer("");
      String l = "";
      String nl = System.getProperty("line.separator");
      boolean start = false;
      while ((l = in.readLine()) !=null) 
      {
        if (l.contains(">Membership"))
        {
          start = true;
          l = in.readLine();
        }
        if (start)
        {  
          if (l.contains("<br /></div>"))
          {
            start = false;
          }
          else
          {
            sb.append(l + nl);
          }
        }
      }
      in.close();
      sb.insert(0, "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">" + nl + "<html>" + nl);
      sb.append("</html>");
      data = sb.toString();
      return data;
    } 
    finally 
    {
      if (in != null) 
      {
        try 
        {
          in.close();
          return data;
        } 
        catch (Exception e) 
        {
          e.printStackTrace();
        }
      }
    }
  }
}




Java Source Code List

Fragments.AboutSectionFragment.java
Fragments.ContactSectionFragment.java
Fragments.EventsSectionFragment.java
Fragments.IsOnlineDialogFragment.java
Fragments.LaunchpadSectionFragment.java
Fragments.SignupSectionFragment.java
Parsers.GetEBoard.java
Parsers.GetMembershipInfo.java
Parsers.GetMissionStatement.java
Parsers.GetVolunteerHours.java
com.github.chrzhang.AboutAdapter.java
com.github.chrzhang.MainActivity.java
com.github.chrzhang.SplashScreen.java