Nedenstående test-prog. tror jeg du kan bruge.
/kama
import java.io.*;
import java.net.*;
import java.util.*;
public class PostTest
{ public static void main(String[] args)
{ try
{
Properties props = new Properties();
URL url = new URL(\"
http://www.census.gov/cgi-bin/ipc/idbsprd\");
props.setProperty(\"tbl\", \"001\");
props.setProperty(\"cty\", \"DA\");
props.setProperty(\"optyr\",\"latest checked\");
String r = doPost(url, props);
System.out.println(r);
}
catch (IOException exception)
{ System.out.println(\"Error: \" + exception);
}
}
public static String doPost(URL url, Properties nameValuePairs) throws IOException
{
URLConnection connection = url.openConnection();
connection.setDoOutput(true);
PrintWriter out = new PrintWriter(connection.getOutputStream());
Enumeration enum = nameValuePairs.keys();
while (enum.hasMoreElements())
{
String name = (String)enum.nextElement();
String value = nameValuePairs.getProperty(name);
char ch;
if (enum.hasMoreElements()) ch = \'&\'; else ch = \'\\n\';
out.print(name + \"=\" + URLEncoder.encode(value) + ch);
}
out.close();
BufferedReader in;
try
{ in = new BufferedReader(new
InputStreamReader(connection.getInputStream()));
}
catch (FileNotFoundException exception)
{ InputStream err
= ((HttpURLConnection)connection).getErrorStream();
if (err == null) throw exception;
in = new BufferedReader(new InputStreamReader(err));
}
StringBuffer response = new StringBuffer();
String line;
while ((line = in.readLine()) != null)
response.append(line + \"\\n\");
in.close();
return response.toString();
}
}