Results 1 to 4 of 4
  1. #1
    john_thomas03 is offline Member
    Join Date
    Jul 2010
    Posts
    6
    Rep Power
    0

    Default java.net.MalformedURLException: no protocol:

    hi tried to run the following code and i am getting the following exception :

    java.net.MalformedURLException: no protocol:

    ************************************

    public static void main(String[] args) throws Exception {
    URL url = new URL("\\xxxx10000d\\a.txt");
    InputStream is = url.openStream();
    BufferedReader br = new BufferedReader(new InputStreamReader(is));

    BufferedReader in = new BufferedReader(
    new InputStreamReader(
    url.openStream()));

    String inputLine;

    while ((inputLine = in.readLine()) != null)
    System.out.println(inputLine);

    in.close();
    }
    }

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,437
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by john_thomas03 View Post
    java.net.MalformedURLException: no protocol:

    URL url = new URL("\\xxxx10000d\\a.txt");
    Ever so right it is: your URL doesn't have a protocol; if it is a file you should supply the URL:

    file://xxxx10000d/a.txt

    Other protocols are similar.

    kind regards,

    Jos

  3. #3
    Zack's Avatar
    Zack is offline Senior Member
    Join Date
    Jun 2010
    Location
    Destiny Islands
    Posts
    692
    Rep Power
    5

    Default

    Pretty sure it's because \\xxxx10000d\\a.txt isn't a URL... what exactly are you trying to access? URLs are from the World Wide Web; they're not really used to access files locally on your computer.

    PS: Ugh! Too slow again. Thanks Jos >.<

  4. #4
    john_thomas03 is offline Member
    Join Date
    Jul 2010
    Posts
    6
    Rep Power
    0

Similar Threads

  1. java.net.MalformedURLException: unknown protocol: ntp
    By Nicholas Jordan in forum Networking
    Replies: 6
    Last Post: 12-24-2008, 03:35 AM
  2. why do I get java.net.MalformedURLException ?
    By aneuryzma in forum New To Java
    Replies: 3
    Last Post: 08-14-2008, 11:57 AM
  3. New Protocol?
    By lada.r in forum Networking
    Replies: 0
    Last Post: 11-06-2007, 09:13 PM
  4. how to use SIP protocol
    By katie in forum Advanced Java
    Replies: 1
    Last Post: 08-06-2007, 10:22 PM
  5. java.net.MalformedURLException
    By mary in forum Advanced Java
    Replies: 1
    Last Post: 07-13-2007, 04:37 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •