Advertisement
Guest User

Try this

a guest
Aug 5th, 2012
2,138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.90 KB | None | 0 0
  1. package javatest;
  2.  
  3.  
  4. import java.io.Console;
  5. import java.util.logging.ConsoleHandler;
  6. import java.net.HttpURLConnection;
  7. import java.net.URL;
  8. import java.io.IOException;
  9. import java.io.InputStream;
  10. import java.io.DataInputStream;
  11. import java.net.MalformedURLException;
  12. import java.io.BufferedInputStream;
  13.  
  14. public class Javatest {
  15.  
  16.     public static void main(String[] args) {
  17.         /*try {
  18.             URL url = new URL("192.168.1.190/index.php");
  19.             HttpURLConnection connection = (HttpURLConnection) url.openConnection();
  20.             connection.addRequestProperty("ok", "yes");
  21.             connection.setDoOutput(true);
  22.             connection.setInstanceFollowRedirects(false);
  23.             connection.setRequestMethod("GET");
  24.             connection.setRequestProperty("Content-Type", "text/plain");
  25.             connection.setRequestProperty("charset", "utf-8");
  26.             connection.connect();
  27.             System.out.println("OK");
  28.         } catch (IOException e) {
  29.             System.out.println("FUCK");
  30.         }*/
  31.        
  32.         String user = p.getName();
  33.         String email = args[0].toString();
  34.         String pass = args[1].toString();
  35.         String urlParameters = "u=" + user + "&e=" + email + "&p=" + pass;
  36.         String request = "http://localhost/uhc/post.php?";
  37.        
  38.         URL url = new URL(request + urlParameters);
  39.         InputStream is = null;
  40.         DataInputStream dis;
  41.         String line;
  42.  
  43.         try {
  44.             url = new URL("http://192.168.1.190/");
  45.             is = url.openStream();  // throws an IOException
  46.             dis = new DataInputStream(new BufferedInputStream(is));
  47.             /* !READ
  48.             while ((line = dis.readLine()) != null) {
  49.                 System.out.println(line);
  50.             }
  51.             */
  52.         } catch (MalformedURLException mue) {
  53.              mue.printStackTrace();
  54.         } catch (IOException ioe) {
  55.              ioe.printStackTrace();
  56.         } finally {
  57.             try {
  58.                 is.close();
  59.             } catch (IOException ioe) {
  60.                 // nothing to see here
  61.             }
  62.         }
  63.  
  64.     }
  65.  
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement