import java.io.*; import java.net.*; public class NewClass2 { public static void main (String args[]) { try { // Construct data // Send data String data="Something"; URL url = new URL("http://www.google.co.uk/"); URLConnection conn = url.openConnection(); conn.setDoOutput(true); conn.setDoInput(true); OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream()); wr.write(data); wr.flush(); // Get the response BufferedReader in = new BufferedReader (new InputStreamReader(conn.getInputStream ())); String temp,response=""; while ((temp = in.readLine()) != null){ response += temp + "\n"; } temp = null; System.out.println("Server response:\n'" + response + "'"); wr.close(); in.close(); } catch (Exception e) { } } }
Page
viewed times
#trackbackRdf ($trackbackUtils.getContentIdentifier($page) $page.title $trackbackUtils.getPingUrl($page))
1 Comment
tvik