Guest User

Untitled

a guest
May 20th, 2020
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.23 KB | None | 0 0
  1.       try{
  2.         URL siturl = new URL("https://web.expasy.org/cgi-bin/protparam/protparam");
  3.         //opening the siturl connection
  4.         HttpURLConnection conn = null;
  5.         conn = (HttpURLConnection)siturl.openConnection();
  6.         conn.setRequestMethod("POST");
  7.         conn.setFollowRedirects(true);
  8.         char[] data=new String("prot_id=P05130&sequence=&mandatory=").toCharArray();
  9.         conn.setRequestProperty("Content-length", String.valueOf(data.length));
  10.         conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
  11.         conn.setDoOutput(true);
  12.         conn.setDoInput(true);
  13.         //setting the output condition to true for printing the contents
  14.         OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream());
  15.         // used to convert character to bytes
  16.         wr.write(data);
  17.         //System.out.println(data);
  18.         wr.flush();
  19.         wr.close();
  20.         // Get the response
  21.         BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
  22.         String line=null;
  23.         while((line=rd.readLine())!=null){
  24.             System.out.println(line);
  25.         }
  26.         }catch(Exception e){
  27.             e.printStackTrace();
  28.         }
Advertisement
Add Comment
Please, Sign In to add comment