Revision: 40889
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at February 9, 2011 14:39 by mouseroot
Initial Code
import java.io.*; import java.net.*; import javax.swing.*; public class Requests { static String domain; static URL myurl; static URLConnection myurlc; static OutputStreamWriter osr; static BufferedReader br; static String line; static String resp; static StringBuilder sb; public Requests(String d) { domain = d; } public String sendPost(String data) { try { sb = new StringBuilder(); myurl = new URL(domain); myurlc = myurl.openConnection(); myurlc.setDoOutput(true); osr = new OutputStreamWriter(myurlc.getOutputStream()); osr.write(data); osr.flush(); br = new BufferedReader(new InputStreamReader(myurlc.getInputStream())); while((line = br.readLine()) != null) { sb.append(line); } br.close(); osr.close(); } catch(IOException e) { JOptionPane.showMessageDialog(null,"IO Error"); } finally { return sb.toString(); } } }
Initial URL
Initial Description
This is a class i put together to handle POST requests
Initial Title
Java Post Requests Class
Initial Tags
Initial Language
Java