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: Which of the subclasses of IOException are more probably to be thrown?

  1. #1
    Junior Member
    Join Date
    Feb 2013
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Which of the subclasses of IOException are more probably to be thrown?

    I want throw (IOException) for this program. But I donít know which of the subclasses of IOException are more likely to be thrown by this program. How should I identify?
    import java.io.*;
    import java.net.*;
    import java.util.ArrayList;
     
    public class SimpleSpider
    {
    	ArrayList<String> set = new ArrayList<String>();
     
    	public void search(String host)
    	{
    		try
    		{
    			URL u = new URL(host);
     
    			set.add(host);
     
    			ArrayList<String> tags = Util.extractTags(u);
    			for (int i = 0; i < tags.size(); i++)
    			{
    				String nexthost = Util.extractURL(tags.get(i));
    				if (nexthost != null && !set.contains(nexthost))
    				{
    					System.out.println(nexthost);
    					search(nexthost);
    				}
    			}
    		}
    		catch (IOException e) {}
    	}
     
    	public static void main (String[] args)
    	{
    		SimpleSpider spider = new SimpleSpider();
    		spider.search("http://en.origami-club.com/");
    	}
    }


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    22,265
    Thanks
    56
    Thanked 2,372 Times in 2,343 Posts

    Default Re: Which of the subclasses of IOException are more probably to be thrown?

    don’t know which of the subclasses of IOException are more likely to be thrown by this program
    Read the API doc for each of the classes inside the try{}catch() block to see what they can throw.
    If you don't understand my answer, don't ignore it, ask a question.

  3. The Following User Says Thank You to Norm For This Useful Post:

    Kate123 (February 15th, 2013)

  4. #3
    Junior Member
    Join Date
    Feb 2013
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: Which of the subclasses of IOException are more probably to be thrown?

    I read the API. I think the most likely to be thrown is : EOFException, InterruptedIOException, UnknownHostException, MalformedURLException... Is there other Exception that is very likely to occur?

  5. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    22,265
    Thanks
    56
    Thanked 2,372 Times in 2,343 Posts

    Default Re: Which of the subclasses of IOException are more probably to be thrown?

    The only one's I expect would be those thrown by the classes and methods used. Those would be listed in the API doc.
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. What Wrong With My Code: IOException.
    By Java Programmer in forum What's Wrong With My Code?
    Replies: 10
    Last Post: January 8th, 2012, 06:11 PM
  2. IOException while accesing files
    By Radha in forum File I/O & Other I/O Streams
    Replies: 2
    Last Post: November 29th, 2011, 06:46 AM
  3. Exception Thrown
    By Frame in forum What's Wrong With My Code?
    Replies: 1
    Last Post: October 30th, 2011, 12:14 AM
  4. EXAMPLE OF FILTERSTREAMS SUBCLASSES.
    By ordonezc78 in forum File I/O & Other I/O Streams
    Replies: 0
    Last Post: March 23rd, 2011, 12:38 AM
  5. caught or declare might be thrown error
    By IDK12 in forum What's Wrong With My Code?
    Replies: 3
    Last Post: January 28th, 2011, 01:55 PM

Tags for this Thread