Advertisement
Guest User

Untitled

a guest
Feb 1st, 2011
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.17 KB | None | 0 0
  1.     private void upload(HttpServletRequest request, HttpServletResponse response) {
  2.         try {
  3.             String url = "http://api.photobucket.com/login/request  ";
  4.             URL endereco = new URL(url);
  5.             HttpURLConnection connection = (HttpURLConnection) endereco.openConnection();
  6.             connection.setRequestMethod("POST");
  7.             connection.setDoInput(true);
  8.             connection.setDoOutput(false);
  9.             connection.connect();
  10.  
  11.             // abre a conexão pra input
  12.             BufferedReader br = new BufferedReader(new InputStreamReader(connection.getInputStream()));
  13.             // le ate o final
  14.             StringBuffer newData = new StringBuffer(10000);
  15.             String s = "";
  16.             while (null != ((s = br.readLine()))) {
  17.                 newData.append(s);
  18.             }
  19.             br.close();
  20.  
  21.             System.out.println(new String(newData));
  22.             System.out.println(connection.getResponseCode() + " " + connection.getResponseMessage());
  23.  
  24.  
  25.         } catch (Exception e) {
  26.             System.out.println("PHOTOBUCKET - UPLOAD");
  27.             System.out.println(e.getMessage());
  28.         }
  29.  
  30.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement