how to connect internet

Discussion in 'Java' started by moon, Aug 12, 2005.

  1. moon

    moon Guest

    Hi Reader

    Below java program work on Proxy server before. Now, Our compary change
    using "Automatic configuration script" to connect internet. Now, I want to
    know how to change the java program ?

    the setup changed to ip address:8081/pixs.pac

    /* Environment variable set to
    * CLASSPATH=c:\j2sdk1.4.1_01\lib\classes.zip;c:\example;.
    *
    */

    import java.util.*;
    import java.io.*;
    import java.net.*;

    public class eproxy_kgi {
    public static void main(String[] args) {
    Properties prop = System.getProperties();
    String myproxy = "xx.xx.xx.xx";
    prop.put("http.proxyHost",myproxy);
    prop.put("http.proxyPort","8081/pixs.pac");
    try {
    // String Addr =
    "http://www.kgieworld.com/kgi_csite/kgidata/indices/s_quote.asp?mnuMarket=HK
    &stockcode=5&partner=";

    String Addr = "http://www.kgieworld.com/kgi_csite/main.asp";
    String outfile = "c:\\temp\\abc.html";

    URL yahoo = new URL(Addr);
    System.out.println("Conneting ... " + Addr);

    BufferedReader in = new BufferedReader(new InputStreamReader
    (yahoo.openStream()));
    BufferedWriter out = new BufferedWriter(new FileWriter(outfile));

    String inputLine;
    System.out.println("Output to " + outfile);
    while ((inputLine = in.readLine()) !=null) {
    out.write(inputLine);
    out.newLine();
    }
    in.close();
    out.close();
    }
    catch (Exception exc) {
    exc.printStackTrace();
    }
    }
    }
     
    moon, Aug 12, 2005
    #1
    1. Advertising

  2. moon

    Roedy Green Guest

    On Fri, 12 Aug 2005 09:36:41 +0800, "moon" <>
    wrote or quoted :

    > Properties prop = System.getProperties();
    > String myproxy = "xx.xx.xx.xx";
    > prop.put("http.proxyHost",myproxy);
    > prop.put("http.proxyPort","8081/pixs.pac");


    try just commenting out those lines. It has been a while since I
    played with dialup.

    You can just ask the user to make the connection first then start your
    program.
     
    Roedy Green, Aug 12, 2005
    #2
    1. Advertising

  3. moon wrote:
    > Hi Reader
    >
    > Below java program work on Proxy server before. Now, Our compary change
    > using "Automatic configuration script" to connect internet. Now, I want to
    > know how to change the java program ?
    >
    > the setup changed to ip address:8081/pixs.pac
    >
    > /* Environment variable set to
    > * CLASSPATH=c:\j2sdk1.4.1_01\lib\classes.zip;c:\example;.
    > *
    > */
    >
    > import java.util.*;
    > import java.io.*;
    > import java.net.*;
    >
    > public class eproxy_kgi {
    > public static void main(String[] args) {
    > Properties prop = System.getProperties();
    > String myproxy = "xx.xx.xx.xx";
    > prop.put("http.proxyHost",myproxy);
    > prop.put("http.proxyPort","8081/pixs.pac");


    Read the proxy.pac script into your browser and take a look at it. It
    shold be easy to understand. It usually consists of a function which
    returns the name of the proxy server depending on the URL. You can see
    what proxy server name you need to code into your java, or how to make
    the decision about which proxy server to use.
     
    ExGuardianReader, Aug 14, 2005
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Otis Mukinfus
    Replies:
    3
    Views:
    959
    Juan T. Llibre
    Jul 8, 2005
  2. Replies:
    3
    Views:
    40,666
    Roedy Green
    Nov 16, 2005
  3. Replies:
    2
    Views:
    327
  4. Mohsen Pahlevanzadeh

    Qt connect and first connect or unicode

    Mohsen Pahlevanzadeh, Sep 17, 2013, in forum: Python
    Replies:
    3
    Views:
    177
    Mohsen Pahlevanzadeh
    Sep 18, 2013
  5. Mohsen Pahlevanzadeh

    Re: Qt connect and first connect or unicode

    Mohsen Pahlevanzadeh, Sep 17, 2013, in forum: Python
    Replies:
    0
    Views:
    137
    Mohsen Pahlevanzadeh
    Sep 17, 2013
Loading...

Share This Page