Created
February 11, 2013 15:28
-
-
Save cory-ko/4755115 to your computer and use it in GitHub Desktop.
Sample script to access G-Links (http://link.g-language.org/) via Java.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.*; | |
import java.net.*; | |
public class GLinks { | |
public static void main(String[] args) { | |
String url_str= "http://link.g-language.org/"; | |
try { | |
URL url= new URL(url_str); | |
HttpURLConnection http= (HttpURLConnection)url.openConnection(); | |
http.setRequestMethod("POST"); | |
http.setDoOutput(true); | |
http.connect(); | |
OutputStreamWriter osw= new OutputStreamWriter(http.getOutputStream()); | |
// hsa:128 and RECA_ECOLI (TSV format) | |
osw.write("query=hsa:128,RECA_ECOLI&format=tsv"); | |
osw.flush(); | |
osw.close(); | |
BufferedInputStream bis= new BufferedInputStream(http.getInputStream()); | |
int data; | |
while ((data = bis.read()) != -1) { | |
System.out.write(data); | |
} | |
} catch(IOException e) { | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment