Mercurial > repos > mikel-egana-aranguren > ncbo_services
comparison get_ontology.java @ 27:e2b16720ef25 draft
Directories re-arranged for easier installation via mercurial
author | Mikel Egana Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu> |
---|---|
date | Mon, 08 Oct 2012 14:25:04 +0200 |
parents | NCBO_services/get_ontology.java@1910c878378c |
children |
comparison
equal
deleted
inserted
replaced
26:354aa87772e0 | 27:e2b16720ef25 |
---|---|
1 package es.upm.fi.dia.oeg.ncbo.galaxy; | |
2 | |
3 import java.io.BufferedReader; | |
4 import java.io.BufferedWriter; | |
5 import java.io.IOException; | |
6 import java.io.InputStream; | |
7 import java.io.InputStreamReader; | |
8 import java.io.OutputStreamWriter; | |
9 | |
10 import org.apache.http.HttpEntity; | |
11 import org.apache.http.HttpResponse; | |
12 import org.apache.http.client.ClientProtocolException; | |
13 import org.apache.http.client.HttpClient; | |
14 import org.apache.http.client.methods.HttpGet; | |
15 import org.apache.http.client.methods.HttpPost; | |
16 import org.apache.http.impl.client.DefaultHttpClient; | |
17 | |
18 public class get_ontology { | |
19 | |
20 /** | |
21 * @param args | |
22 * @throws IOException | |
23 * @throws ClientProtocolException | |
24 */ | |
25 public static void main(String[] args) throws ClientProtocolException, IOException { | |
26 String api_key = args [0]; | |
27 String ontology_id = args [1]; // 1522 | |
28 HttpClient client = new DefaultHttpClient(); | |
29 | |
30 HttpGet get = new HttpGet("http://rest.bioontology.org/bioportal/virtual/download/" + ontology_id + "?apikey=" +api_key); | |
31 HttpResponse response = client.execute(get); | |
32 HttpEntity entity = response.getEntity(); | |
33 if (entity != null) { | |
34 InputStream instream = entity.getContent(); | |
35 InputStreamReader is=new InputStreamReader(instream); | |
36 BufferedReader br=new BufferedReader(is); | |
37 String read=br.readLine(); | |
38 BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); | |
39 while(read!=null){ | |
40 // System.out.println(read); | |
41 bw.write(read); | |
42 bw.newLine(); | |
43 read=br.readLine(); | |
44 } | |
45 bw.close(); | |
46 instream.close(); | |
47 } | |
48 } | |
49 } |