DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 2 of 2
  1. #1
    Join Date
    Nov 2005
    Posts
    1

    Problem creatingan Inputstream from a URLconnection

    Hi, all

    SORRY ALL- it was my mistake, I should have put "/" before the filename

    ---------------------------------------------------------------------
    >I have a problem creating an InputStream object here is the code :
    Code:
    URL url = new URL("http", "archive.ncsa.uiuc.edu", -1, "SDG/Software/Mosaic/Demo/url-primer.html");
    			URLConnection urlc = url.openConnection();
    			urlc.connect();
    			InputStream input = urlc.getInputStream();
    >I get the following exception error:
    Code:
    Exception in thread "main" java.io.IOException: Server returned HTTP response code: 400 for URL: http://archive.ncsa.uiuc.eduSDG/Software/Mosaic/Demo/url-primer.html
    	at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
    	at Url.main(Url.java:9)
    >Thnx in advance
    -----------------------------------------------------------------
    Last edited by Kurapica; 11-04-2005 at 11:17 AM.

  2. #2
    Join Date
    Nov 2004
    Location
    Norway
    Posts
    1,560
    It works ok if you write the file spec right, with a leading slash:

    URL url = new URL("http", "archive.ncsa.uiuc.edu", -1, "/SDG/Software/Mosaic/Demo/url-primer.html");

    btw, it works fine without this statement too:

    urlc.connect();
    eschew obfuscation

Similar Threads

  1. Problem with Search
    By Irina in forum ASP.NET
    Replies: 0
    Last Post: 11-29-2002, 10:47 PM
  2. Replies: 0
    Last Post: 12-13-2001, 12:06 PM
  3. Replies: 0
    Last Post: 09-08-2000, 09:41 AM
  4. Arabic problem view
    By Ayman in forum VB Classic
    Replies: 8
    Last Post: 04-03-2000, 08:13 PM
  5. Problem with CryptoAPI and JCE
    By Jason Bock in forum VB Classic
    Replies: 0
    Last Post: 03-21-2000, 06:48 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links