comparison NCBO_services/get_ontology.java @ 26:354aa87772e0

Uploaded
author jose-minyarro
date Mon, 19 Mar 2012 08:25:59 -0400
parents 1910c878378c
children
comparison
equal deleted inserted replaced
25:c324108a12ce 26:354aa87772e0
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 }