[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now



Posted on 1997-08-19
Medium Priority
Last Modified: 2012-06-21

I'm trying to write a snippet of code, to determine if a URL-documnet
exists, before I use it with the AppletContext.showDocument-method, and
it looks like this:

private boolean fileExist(URL url)
            try {
                InputStream testStream = url.openStream();
                } catch (IOException ioe) {
                    return false;
            return true;

, but it doesn't seem to work!

NetScape's implementation of Java doesn't seems to catch the IOException
at all!

Is there a better way?
Question by:atti
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Accepted Solution

mnelson051997 earned 50 total points
ID: 1225411
It worked Ok for me in netscape 3.01.  Following is the
full text of the applet that returned false:

import java.io.*;
import java.net.*;
import java.applet.*;

public class Test1 extends Applet
   public void init()

      // Returns false.

      System.out.println( fileExist( new URL( "http://www.zeh.crom" ) ) );

      // Returns true.

      //System.out.println( fileExist( new URL( "http://www.zeh.com" ) ) );
      }catch(Exception e ) { System.out.println( "--"+e ); }

   private static boolean fileExist(URL url)
       try {
       InputStream testStream = url.openStream();
       } catch (IOException ioe) {
       return false;
       return true;

Are you running a different version of Netscape?

Author Comment

ID: 1225412
Are you running a different version of Netscape?
Yes, I'm running Netscape 4 and it doesn't work.... :-(

Featured Post

Tech or Treat!

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
Suggested Courses

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question