GetURL needs to incorporate username and password!!!!

Hi,
I need a Java program to go to a URL and then save the web page in a text file. I have successfully done this by finding the GetURL method (see bottom of page). But I need to do it for a URL where a standard username and password prompt appears. I know I need to use the following piece of code somewhere in the GetURL program to bypass this authorisation:
HTTPConnection con = new HTTPConnection(this);
con.addBasicAuthorization("protected-space", "goofy", "woof");
The problem is that I am a complete Java novice and am desperately trying to finish a project, therefore I just don�t have the time to learn the language.
Can someone PLEASEEEEEEE tell me how I can incorporate the above code into the following GetURL program (which I know works for URL�s without the authorisation needed):
[by the way, the URL is in the program below and the username = Bazza99  and the password = upge5w7u]
import java.io.*;
import java.net.*;
* This simple program uses the URL class and its openStream() method to
* download the contents of a URL and copy them to a file or to the console.
public class GetURL {
public static void main(String[] args) {
InputStream in = null;
OutputStream out = null;
try {
// Check the arguments
if ((args.length != 1) && (args.length != 2))
throw new IllegalArgumentException("Wrong number of arguments");
// Set up the streams
URL url = new URL("http://www.advfn.com/cmn/fun/advfnFun.php?epic=BAA"); // Create the URL
in = url.openStream(); // Open a stream to it
if (args.length == 2) // Get an appropriate output stream
out = new FileOutputStream("badata.txt");
else out = System.out;
// Now copy bytes from the URL to the output stream
byte[] buffer = new byte[4096];
int bytes_read;
while((bytes_read = in.read(buffer)) != -1)
out.write(buffer, 0, bytes_read);
// On exceptions, print error message and usage message.
catch (Exception e) {
System.err.println(e);
System.err.println("Usage: java GetURL <URL> [<filename>]");
finally {  // Always close the streams, no matter what.
try { in.close();  out.close(); } catch (Exception e) {}

Hi,
I wasn't sure how to incorporate your code into the GetURL program (afriad I am a java novice). I tried to run the code at the bottom of the page but it came back with the following error:
java.io.FileNotFoundException: http://www.advfn.com/cmn/fun/advfnFun.php?epic=BAA
Usage: java GetURL <URL> [<filename>]
code run:
import java.io.*;
import java.net.*;
* This simple program uses the URL class and its openStream() method to
* download the contents of a URL and copy them to a file or to the console.
public class GetURL {
public static void main(String[] args) {
InputStream in = null;
OutputStream out = null;
try {
// Check the arguments
if ((args.length != 1) && (args.length != 2))
throw new IllegalArgumentException("Wrong number of arguments");
// Set up the streams
URL url = new
URL("http://www.advfn.com/cmn/fun/advfnFun.php?epic=BAA"); // Create the URL
URLConnection conn = url.openConnection();
conn.setRequestProperty("Authorization", "Basic " + new
sun.misc.BASE64Encoder().encode("(Bazza99):(upge5w7u)".getBytes()));
in = conn.getInputStream();
if (args.length == 2) // Get an appropriate output stream
out = new FileOutputStream("baadata.txt");
else out = System.out;
// Now copy bytes from the URL to the output stream
byte[] buffer = new byte[4096];
int bytes_read;
while((bytes_read = in.read(buffer)) != -1)
out.write(buffer, 0, bytes_read);
// On exceptions, print error message and usage message.
catch (Exception e) {
System.err.println(e);
System.err.println("Usage: java GetURL <URL> [<filename>]");
finally {  // Always close the streams, no matter what.
try { in.close();  out.close(); } catch (Exception e) {}

Similar Messages

  • WS-security Need to Get Username and Password and time Stamp in SOAP Header

    HI ALL,
    i need to get USERNAME and PWD in my Soap header for consuming Webservice using SAP PI ,
    and my SOAP Header should look like this
    <soapenv:Header>
    <wsse:Security soapenv:mustUnderstand="1"
    xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
    xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurityutility-
    1.0.xsd"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wsswssecurity-
    secext-1.0.xsd">
    <wsu:Timestamp wsu:Id="Timestamp-296915943">
    <wsu:Created>2008-06-05T18:30:59.904Z</wsu:Created>
    <wsu:Expires>2009-06-05T18:35:59.904Z</wsu:Expires>
    </wsu:Timestamp>
    <wsse:UsernameToken wsu:Id="UsernameToken-192809888">
    <wsse:Username>midtier-service</wsse:Username>
    xxxxxxxx: Confidential Green 10
    <wsse:Password Type="http://docs.oasisopen.
    org/wss/2004/01/oasis-200401-wss-username-token-profile-
    1.0#PasswordText">password</wsse:Password>
    </wsse:UsernameToken>
    </wsse:Security>
    </soapenv:Header>
    should i need to get some certificates from client and deploy it or should we do anything in SAP PI and send to soap header or can hard code it and send to webservice, please help me in this t
    hanking you
    Sridhar

    i need to get USERNAME and PWD in my Soap header for consuming Webservice using SAP PI ,
    Can be achieved by XSL Mapping or SOAP Axis Adapter. Search on SDN for further details as this has been discussed many a times on the forum.
    should i need to get some certificates from client and deploy it or should we do anything in SAP PI and send to soap header or can hard code it and send to webservice, please help me in this t
    First you need to confirm whether certificates are required or not. Might be the web service is using user id / password security (basic authorization).
    How to use certificates in PI - Search on SAP Help, this has been explained in great details over there.

  • Need to Change Username and Password

    I seriously need to find a way to change the router's login Username and Password.
    I live in an apartment building, and someone is logging into my router and disabling my wireless security every other week.
    So far, everywhere I've read has said that you can't change the login username and password, only the administrator password, but the Login defaults of "admin" are just too easy for people to hack into.
    I need a way to secure my network so that Only I can log in to make any changes to my network.

    Also, check the logs (enable them if they are not enabled) to see if you are actually getting "hacked" or the device is just restoring to factory default.

  • How can I get the username and password from Oracle Forms to PJC !

    Dear Sir,
    I have username,password and push button fields in oracle forms. When user clicks the push button, I need to get username and password field contents to my Pluggable Java Program to authenticate the user trying to login. How can I get those text field contents to my java program..? Looking forward from you soon sir.
    Thanks in Advance,
    S Ramkumar

    I tried that trigger but nothing reflects. I write that method in WHEN_BUTTON_PRESSED trigger.
    In the form module I written,
    Set_Custom_Property('BL.USERNAME',1,'NAME','');
    Set_Custom_Property('BL.PASSWORD',1,'PASS','');
    Implementation class of the push button I gave my java class file name.
    In Java Code I tried register the form fields like,
    public static final ID userName = ID.registerProperty("NAME");
    public static final ID passWord = ID.registerProperty("PASS");
    In Java Code I tried get the contents from registered properties,
    public boolean setProperty(ID property, Object value) {
    if(property == userName) {
    System.out.println("Just I wish to see the name entered" + value.toString());
    if(property == passWord) {
    System.out.println("Just I wish to see the pass entered" + value.toString());
    But even System.out.println() is working.
    What's wrong with this code sir ???
    Can you tell me How to register and get those field values in Java ?

  • How to set username and password when using Proxy class for SOCKS5?

    Hi all,
    I use the proxy class for SOCKS5, so need to set username and password, I don't find where can I set the value. whether the API support it.
    Thanks in advance!

    System.getProperties().put("proxySet", "true");That does nothing. Remove.
    System.getProperties().put("proxyHost", getProxyHost());
    System.getProperties().put("proxyPort", getProxyPort());You should be setting socks.proxyHost and socks.proxyPort here.
    System.setProperty("java.net.socks.username", getSOCKSUsername());
    System.setProperty("java.net.socks.password", getSOCKSPassword());
    Authenticator.setDefault(new ProxyAuth(getSOCKSUsername(), getSOCKSPassword()));You either need the first two lines or the third, not both. See the last link posted above.
    1. After I set the value, I connect internet by proxy, how the proxy server knows the values?Because Java tells it during the SOCKS handshake.
    2. In my app, I just set the values in the system properties, then JVM does remaining work? Remaining work is not concerned?Should be OK unless you have to connect to a different SOCKS proxy from the same JVM, but that kind of thing is problematic anyway due to the curious Authenticator design which is set globally, not per connection as you might expect.

  • Device username and password

    I wanted to add an Email address to my phone book. I went to Email setup and needed my device username and password. It doesn't like my entries so I must have forgotten them. How can I retrieve them? I have too many after all these years and thought I wrote the BB device down.

    then you need to call your carrier and have your BIS account cancelled and re-added.
    And write it down this time.
    1. If any post helps you please click the below the post(s) that helped you.
    2. Please resolve your thread by marking the post "Solution?" which solved it for you!
    3. Install free BlackBerry Protect today for backups of contacts and data.
    4. Guide to Unlocking your BlackBerry & Unlock Codes
    Join our BBM Channels (Beta)
    BlackBerry Support Forums Channel
    PIN: C0001B7B4   Display/Scan Bar Code
    Knowledge Base Updates
    PIN: C0005A9AA   Display/Scan Bar Code

  • ActionTec GT701D DSL Modem; DSL username and password

    I am about to try to install the above modem and an Apple AirPort Extreme Wifi router.  The modem says I will need my DSL username and password, but when I telephoned Verizon support the rep said I could make up any number and password.
    I don't think he is correct.  Where do I go to find my DSL username and password?  It has been so long since I installed the current modem and wifi router that I have forgotten what the related username and password may be.
    Can I get a little help from the community?

    The DSL modem username and password can be the following below, but to be sure, are you looking for the PPPoE username and password? That's something different and is what actually connects up your DSL connection so that you can get connected to the Internet.
    Modem Logins: 
    admin/password
    admin/password1
    admin/admin
    admin/admin1
    admin/verizon
    admin/verizon1
    As for the PPPoE login, this is the Username and password which was created, or is otherwise known as the master password to your Verizon account. This is typically the master account that you use to log into MyVerizon. Otherwise, the Verizon agent is likely correct. In my area you CAN punch in any username and password, or for that matter leave that info blank and you'll get a connection.
    ========
    The first to bring me 1Gbps Fiber for $30/m wins!

  • External Application username and password

    Hi All,
    I need a specific requirement. When the user login to externa application first time, whether it stores this username password in any table or somewhere.. Actually i need external application username and password for other purpose. I need that in another application i.e. outside of the External Application. How to call that API to get that info. Is there any otherway to get that.
    I thought of doing that, with the use of ExternalPrincipal class, but for we need SSO username and password to instatiate that class. I got some info that, we cannnot get the SSO password. Is there any way to get SSO password. Please help me in this regard.. It is very urgent for me..
    Thanks
    Damodar

    The username and password for a particular external application is stored in the WWSSO_APPUSERINFO_T table in the ORASSO schema. The external application is referenced via the app_id, which corresponds to an external application identified in the WWSSO_APPLICATION_INFO_T table in the ORASSO schema.
    To get the ORASSO password in OID, use my GETPASS.CMD file found in my Knowledge Exchange. This file also extracts the passwords for PORTAL, ORASSO_PA and ORASSO_PS.
    HTH
    LLB

  • Browser need proxy username and password

    this code works fine without a proxy, however i can figuer out how to get it to work when behind a proxy, i tried some different things to pass the proxy username and password(the commented out code) but those did work, can anyone help with this? cause im lost as to how to send the proxy credentials to get outside to the net
    import java.awt.*;
    import java.awt.event.*;
    import java.net.*;
    import java.io.*;
    import javax.swing.*;
    import javax.swing.event.*;
    public class ReadServerFile extends JFrame {
    private JTextField enter;
    private JEditorPane contents;
    public ReadServerFile(){
    super ("Rage");
    System.getProperties().put("proxySet","true");
    System.getProperties().put("proxyPort","80");
    System.getProperties().put("proxyHost","90.8.0.5");
    //need to set the username and password
    //System.setProperty("http.proxyUser","sservices/proglab30");
    //System.setProperty("http.proxyPassword","proglab30");
    //Authenticator.setDefault(new Authenticator()
    // protected PasswordAuthentication getPasswordAuthentication()
    //   return new PasswordAuthentication("proglab30","proglab30".toCharArray());
    Container c = getContentPane();
    enter = new JTextField("http://www.google.com/");
    enter.addActionListener(new ActionListener()
    {public void actionPerformed (ActionEvent e)
    {getThePage(e.getActionCommand());}});
    c.add( enter, BorderLayout.NORTH);
    contents = new JEditorPane();
    contents.setEditable(false);
    contents.addHyperlinkListener(
    new HyperlinkListener(){
    public void hyperlinkUpdate(HyperlinkEvent e)
        if (e.getEventType()==
        HyperlinkEvent.EventType.ACTIVATED)
        getThePage(e.getURL().toString());}});
    c.add(new JScrollPane(contents), BorderLayout.CENTER);
    setSize(400,300);
    show();
    private void getThePage(String location)
    setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
    try {
    contents.setPage(location);
    enter.setText(location);
    catch(IOException io)
      JOptionPane.showMessageDialog(this,"Error getting URL","Bad URL",JOptionPane.ERROR_MESSAGE);
    setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
    public static void main (String args[])
      ReadServerFile app= new ReadServerFile();
      app.addWindowListener(new WindowAdapter(){
        public void windowClosing(WindowEvent e)
          System.exit(0);
    }

    ray,
    Sounds like a permission problem.
    Try running these.
    ColdFusionDirectory\bin\connectors\Remove_ALL_connectors.bat
    ColdFusionDirectory\bin\connectors\IIS_connector.bat
    Ken Ford
    Adobe Community Expert
    Fordwebs, LLC
    http://www.fordwebs.com
    "RayBees" <[email protected]> wrote in message
    news:ek727f$bnq$[email protected]..
    > Greetings
    >
    > I have an interesting problem. When I browse certain
    section of my website
    > I
    > am asked to enter my username and password. When clicked
    "cancel" twice
    > the
    > person is let throught to the page. This seems to be
    related to the cfform
    > tage. If I remove the tag, I am no longer asked for the
    username and
    > password.
    > This happens in IE 6 and 7, Netscape 7.1 but not in
    Firefox 1.5 or Mozilla
    > 1.5.
    >
    > But here is where it gets really interesting, If I log
    onto the web
    > server,
    > every page asks for the username and password. Any
    thoughts?
    >
    > Thanks
    > Ray
    >
    > The Specs
    > CFMX 7.02
    > Windows 2003
    > IIS 6
    >

  • How to connect an apple tv to an enterprise network with a username and a password?   I need to use it over my university's wifi. theres no option to enter username and password. how to connect the apple tv to such enterprise network?

    How to connect an apple tv to an enterprise network with a username and a password?
    I need to use it over my university's wifi. theres no option to enter username and password. how to connect the apple tv to such enterprise network?

    Contact the University's IT dept, they may be able to set something up on the network to allow the ATV to connect without the need for a user name/password.

  • I am the founder of a non-profit organization, a donor had just given us her used iBook G4.  What do I need to do to wipe out her "stuff", change username and password, start all over new.  We will use this iBook in our learning center in Saigon, Vietnam

    To good citizens of the MAC world,
    I am the founder of a non-profit organization, we are caring for 6,200 orphans and street kids in Vietnam.  A donor had just donated her used iBook G4 for us to use in one of our several "learning centers" in Vietnam.  Folks sometimes donating PC but this is the first time we ever received a MAC.. :-)  I would like to know how to start this iBook all over new: change username and password.  I am looking so forward to bring it to Saigon in a few days and let our children experience MAC ... I am a 2 years MAC users and I have no intention to return to the Dark side.  Please help. I have the original OS disk.  Thank you so much.

    There should be no need to zero the hard drive.
    Using the Restore discs that came with the iBook when it was new, restore the system software using the appropriate instructions which you can find through a link contained in this Apple Knowledge Base article:
    http://support.apple.com/kb/HT1561?viewlocale=en_US
    Good luck with it.

  • Im trying to listen to a book and it keeps telling me I need to enter my audible account username and password.  I used my apple id and it is not working anyone know what to do?

    Im trying to listen to a book we downloaded from amazon.  When we click on it it says we need to enter out audible username and password.  I used my apple id username and password and it says it is not correct.  I reset this and used it again and it still does not work.  Any ideas?

    Launch iTunes. From the menu bar click Store / View My Account then click Edit Payment Information.
    Make sure the Security Code for you credit card is available and the expiration date is correct, then click Done.

  • Ical in outlook needs a username and password

    Hello,
    I am using a shared calendar in icloud and want to add this to outlook.  I have sent the invite to my outlook account and it has an address like webcal://p04-calendarws.icloud.com/ca/subscribe/1..
    When I click on the link it asks me if I would like to "add this internet calendar to outlook..".  If I click yes, it firstly asks me for a user name and password.  I have tried my iCloud credentials but these did not work.  After this has failed, outlook then says:"can not verify or add this calendar to outlook".
    Can anybody help and let me know what I need to do (not okay to add the icloud add-in to outlook as I am using a work computer and running XP and Office 2007).
    I would also like to sync the contacts as well.  Is this possible too?
    Many thanks,
    Nick.

    Printers do not work with networks that require a username and password to communicate on the network.  Sorry.
    The only way you will be able to use the printer wirelessly is through an ad-hoc connection.  This means the computer will not an Internet connection while it is connected to the printer's ad-hoc network unless the computer has two network connections available (2 wireless or 1 wireless and 1 wired).
    The top of page 138 of the manual details how to connect to the printer's ad-hoc network.
    Let me know what happens.
    ↙-----------How do I give Kudos?| How do I mark a post as Solved? ----------------↓

  • Need username and password

    I am replacing my standard issue dsl modem with a non verizon modem/wireless router combo unit.  It says in the install instructions that I need to have my dsl username and password.  I would rather not have to call verizon customer service (never had a issue, but jsut a pain to call with those voice activated menus), so I am wondering is this the same username/password I use to access my email, etc. at verizon's website?  Or some information used by my current modem that is totally different?

    The Username and Password would be the User/Pass to access to your Verizon e-mail, yes. If it isn't that, it would be the User/Pass to the Master account if you use a Subaccount for e-mail. Hope I'm clear enough with that.
    It might be worth pointing out that if your Westell modem was using DHCP and not PPPoE to connect to Verizon, you do not need a Login. Instead, all you need to do is leave the modem powered off for a few hours to allow the DHCP lease to break from the old modem, or you need to clone the MAC address of the old modem to the new modem. Otherwise, if you are in a PPPoE area that uses OpenPPPoE such as my area, you can use any Username/Password combination you'd like and it will connect.
    ========
    The first to bring me 1Gbps Fiber for $30/m wins!

  • Which username and password need to give to access reports in portal

    Hi all,
    I had created a system object to a development server and get connected to development server.  I created a sample trasactional Iview and attached to a role.
    when i am viewing its showing a screen to give username and password.
    <b>which username and paasword i need to give here</b>. so that i can provide user mapping .

    Hi Pratap,
    You need the user name and password of the backend server (the one you named "development server", if you talk of a transactional iView, it is probably an R/3 system?! Which user you have on that side with the right permission nobody know. For SSO you could set up SSO via SSO2 tickets, if the user basis is the same on the backend system as on the portal server.
    Hope it helps
    Detlev

Maybe you are looking for

  • Deleting a row from a Parent VO gives NullPointerException

    I am using JDev 11.1.1.2.0 Deleting a row from a Parent VO gives NullPointerException raised from oracle.jbo.server.EntityImpl.vetoRemoveWithDetails(EntityImpl.java:8214) Here is my implementation: There are two Entity Objects(Named "Parent" and "Chi

  • Outbound character sets

    Hi Our outbound external messages go out via a GW704 GWIA. The GWIA thenpasses them onto our email security gateway. The issue that I'm having is that I've enabled a 'disclaimer' on our email security gateway that is stamped on all outbound messages.

  • Why SSIS package returning 5

    Hi, I am facing issues and unable to resove it. We made SSIS package in dev environment in windows 2008R2 and SQL server 2012. Same packages were placed on SAN disks in cluster environment and are invokded with security contexxt of admin user and wih

  • Please help me assign channel names

    Hi Im trying to log select data when any of 24 signals rises above 5 V which I have done with Greater or Equal Express VI. I'm having a hard time getting this data to my file via Write to Measurement File. A waveform plot that I have connected to thi

  • Cfloop query and last row

    Hello everyone, I was trying looping over a query which has to be executed only when the last row of a previous loop has been reached. The question is: I have nested loops, I am able to print the values based on two loops: for example: <cfloop query=