Child pages
  • HTML-info fel és vissza-java kóddal
Skip to end of metadata
Go to start of metadata
  1. import java.io.*;
  2. import java.net.*;
  3. public class NewClass2
  4. {
  5. public static void main (String args[])
  6. {
  7. try
  8. {
  9. // Construct data
  10.  
  11. // Send data
  12. String data="Something";
  13. URL url = new URL("http://www.google.co.uk/");
  14. URLConnection conn = url.openConnection();
  15. conn.setDoOutput(true);
  16. conn.setDoInput(true);
  17. OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream());
  18. wr.write(data);
  19. wr.flush();
  20.  
  21. // Get the response
  22. BufferedReader in = new BufferedReader (new InputStreamReader(conn.getInputStream ()));
  23. String temp,response="";
  24. while ((temp = in.readLine()) != null){
  25. response += temp + "\n";
  26. }
  27. temp = null;
  28.  
  29. System.out.println("Server response:\n'" + response + "'");
  30. wr.close();
  31.  
  32. in.close();
  33. }
  34. catch (Exception e)
  35. {
  36.  
  37. }
  38. }
  39. }
Ez lenne  kód ami csatlakozik a google oldalára, beír egy szöveget a keresőbe és a vissza kapott új html kódot kéne hogy kiírja .De mivel nem ír ki semmit ezért valószinűleg nem kap vissza semmilyen válaszkódot....nem tudom mi lehet a probléma...
      
      
Page viewed times
#trackbackRdf ($trackbackUtils.getContentIdentifier($page) $page.title $trackbackUtils.getPingUrl($page))
  • No labels

1 Comment

  1. Azon elgondolkodtál már, hogy ha az üres catch blokkban lenne printStackTrace, az vajon kiírna-e valamit?