예제 #1
0
  private Job getJobFromUrl(String url) {
    try {
      HttpGet httpget = new HttpGet(url);
      HttpClient client = new DefaultHttpClient();
      HttpResponse response = client.execute(httpget);
      InputStream in = response.getEntity().getContent();

      BufferedReader reader = new BufferedReader(new InputStreamReader(in));
      StringBuilder str = new StringBuilder();
      String line, html = null;
      while ((line = reader.readLine()) != null) {
        str.append(line);
      }
      in.close();
      String xml = str.toString();
      String color = fromXmlToColor(xml);
      Status status = fromColorToStatus(color);
      Job job = new Job(status);
      job.setColor(color);
      job.setUrl(url);

      return job;

    } catch (Exception ex) {
      System.err.println("Could not get Url: " + ex);
      return null;
    }
  }