Advertisement
Corosus

Untitled

Feb 13th, 2012
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.43 KB | None | 0 0
  1. package net.minecraft.client;
  2.  
  3. import java.io.BufferedReader;
  4. import java.io.DataOutputStream;
  5. import java.io.File;
  6. import java.io.InputStream;
  7. import java.io.InputStreamReader;
  8. import java.net.HttpURLConnection;
  9. import java.net.URL;
  10. //import net.minecraft.Util_OS;
  11.  
  12. public class Util {
  13.  
  14. private static File workDir = null;
  15. // $FF: synthetic field
  16. private static int[] $SWITCH_TABLE$net$minecraft$Util$OS;
  17.  
  18.  
  19. public Util() {
  20. super();
  21. }
  22.  
  23.  
  24.  
  25. public static String excutePost(String targetURL, String urlParameters) {
  26. HttpURLConnection connection = null;
  27. boolean var13 = false;
  28.  
  29. String var10;
  30. label84: {
  31. try {
  32. var13 = true;
  33. URL url = new URL(targetURL);
  34. connection = (HttpURLConnection)url.openConnection();
  35. connection.setRequestMethod("POST");
  36. connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
  37. connection.setRequestProperty("Content-Length", Integer.toString(urlParameters.getBytes().length));
  38. connection.setRequestProperty("Content-Language", "en-US");
  39. connection.setUseCaches(false);
  40. connection.setDoInput(true);
  41. connection.setDoOutput(true);
  42. DataOutputStream e = new DataOutputStream(connection.getOutputStream());
  43. e.writeBytes(urlParameters);
  44. e.flush();
  45. e.close();
  46. InputStream is = connection.getInputStream();
  47. BufferedReader rd = new BufferedReader(new InputStreamReader(is));
  48. StringBuffer response = new StringBuffer();
  49.  
  50. String line;
  51. while((line = rd.readLine()) != null) {
  52. response.append(line);
  53. response.append('\r');
  54. }
  55.  
  56. rd.close();
  57. var10 = response.toString();
  58. var13 = false;
  59. break label84;
  60. } catch (Exception var14) {
  61. var14.printStackTrace();
  62. var13 = false;
  63. } finally {
  64. if(var13) {
  65. if(connection != null) {
  66. connection.disconnect();
  67. }
  68.  
  69. }
  70. }
  71.  
  72. if(connection != null) {
  73. connection.disconnect();
  74. }
  75.  
  76. return null;
  77. }
  78.  
  79. if(connection != null) {
  80. connection.disconnect();
  81. }
  82.  
  83. return var10;
  84. }
  85.  
  86.  
  87. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement