Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void upload(HttpServletRequest request, HttpServletResponse response) {
- try {
- String url = "http://api.photobucket.com/login/request ";
- URL endereco = new URL(url);
- HttpURLConnection connection = (HttpURLConnection) endereco.openConnection();
- connection.setRequestMethod("POST");
- connection.setDoInput(true);
- connection.setDoOutput(false);
- connection.connect();
- // abre a conexão pra input
- BufferedReader br = new BufferedReader(new InputStreamReader(connection.getInputStream()));
- // le ate o final
- StringBuffer newData = new StringBuffer(10000);
- String s = "";
- while (null != ((s = br.readLine()))) {
- newData.append(s);
- }
- br.close();
- System.out.println(new String(newData));
- System.out.println(connection.getResponseCode() + " " + connection.getResponseMessage());
- } catch (Exception e) {
- System.out.println("PHOTOBUCKET - UPLOAD");
- System.out.println(e.getMessage());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement