Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: Network Program

  1. #1
    Junior Member
    Join Date
    Apr 2014
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Network Program

     
    // File Name : URLDemo.java 
    import java.net.*; 
    import java.io.*; 
    public class URLDemo 
    { 
    public static void main(String[] args) 
    {
    try { 
    URL url =new URL(args[0]); 
    System.out.println("URL is "+ url.toString()); 
    System.out.println("protocol is "+ url.getProtocol()); 
    System.out.println("authority is "+ url.getAuthority()); 
    System.out.println("file name is "+ url.getFile()); 
    System.out.println("host is "+ url.getHost()); 
    System.out.println("path is "+ url.getPath()); 
    System.out.println("port is "+ url.getPort()); 
    System.out.println("default port is "+ url.getDefaultPort()); 
    System.out.println("query is "+ url.getQuery()); 
    System.out.println("ref is "+ url.getRef()); 
    }catch(IOException e) 
    { 
    e.printStackTrace(); 
    } 
    } 
    }


  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,301
    Thanks
    181
    Thanked 824 Times in 767 Posts
    Blog Entries
    5

    Default Re: Network Program

    Do you have a question?

  3. #3
    Junior Member
    Join Date
    Apr 2014
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Network Program

    Error:
    It gives me ArrayIndexOutOfBoundException
    at location Url url = new Url(args[0]);

    what should I do?

  4. #4
    Junior Member
    Join Date
    Apr 2014
    Posts
    3
    My Mood
    Happy
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Network Program

    I think you are not providing "Run Time Arguement" that's why it gives ArrayIndexOutOfBoundException.

Similar Threads

  1. Network Management
    By ramzi.tellissi in forum Java Networking
    Replies: 1
    Last Post: January 31st, 2014, 05:38 AM
  2. install network program
    By ferrarini in forum What's Wrong With My Code?
    Replies: 32
    Last Post: May 30th, 2012, 01:05 PM
  3. Java Network performance analyser program help
    By Tark221 in forum Java Theory & Questions
    Replies: 4
    Last Post: March 22nd, 2011, 01:02 PM
  4. network scanner
    By vivek494818 in forum Java Networking
    Replies: 0
    Last Post: August 17th, 2009, 11:07 PM