Exemple #1
0
 @Override
 public String doInBackground(String... params) {
   HttpDownloader loader = new HttpDownloader();
   String result = loader.download(params[0]);
   System.out.println("xml------>" + result);
   return result;
 }
Exemple #2
0
  public WordUrl(String danci) {
    HttpDownloader httpDownloader = new HttpDownloader();

    String lrc =
        httpDownloader.download(
            33,
            "http://dict.youdao.com/m/search?q=" + danci + "&keyfrom=smartresult.dict.m#hanhan",
            -1);
    lrc = lrc.replaceAll("有道", "易记");
    lrc = lrc.replaceAll("youdao", "yiji");
    lrc = lrc.replaceAll("网易公司", "周卓潜出品");
    meaning = lrc;
  }
 protected SkyValue compute(Environment env, Rule rule) throws RepositoryFunctionException {
   // The output directory is always under .external-repository (to stay out of the way of
   // artifacts from this repository) and uses the rule's name to avoid conflicts with other
   // remote repository rules. For example, suppose you had the following WORKSPACE file:
   //
   // http_archive(name = "png", url = "http://example.com/downloads/png.tar.gz", sha256 = "...")
   //
   // This would download png.tar.gz to .external-repository/png/png.tar.gz.
   Path outputDirectory = getExternalRepositoryDirectory().getRelative(rule.getName());
   FileValue directoryValue = createDirectory(outputDirectory, env);
   if (directoryValue == null) {
     return null;
   }
   AggregatingAttributeMapper mapper = AggregatingAttributeMapper.of(rule);
   URL url = null;
   try {
     url = new URL(mapper.get("url", Type.STRING));
   } catch (MalformedURLException e) {
     throw new RepositoryFunctionException(
         new EvalException(rule.getLocation(), "Error parsing URL: " + e.getMessage()),
         Transience.PERSISTENT);
   }
   String sha256 = mapper.get("sha256", Type.STRING);
   HttpDownloader downloader = new HttpDownloader(url, sha256, outputDirectory);
   try {
     Path archiveFile = downloader.download();
     outputDirectory =
         DecompressorFactory.create(
                 rule.getTargetKind(), rule.getName(), archiveFile, outputDirectory)
             .decompress();
   } catch (IOException e) {
     // Assumes all IO errors transient.
     throw new RepositoryFunctionException(e, Transience.TRANSIENT);
   } catch (DecompressorException e) {
     throw new RepositoryFunctionException(new IOException(e.getMessage()), Transience.TRANSIENT);
   }
   return new RepositoryValue(outputDirectory, directoryValue);
 }
Exemple #4
0
 private String downloadXML() {
   HttpDownloader httpDownloader = new HttpDownloader();
   String result = httpDownloader.download(AppConstant.URL.BASE_URL + "resources.xml");
   return result;
 }