Posted on 1997-08-19
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.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( "" ) ) );
      }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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
login jsp example 24 101
servlet and mdb, jms error 1 79
running on tomcat not jboss eap 7.0 3 50
program arguments vs VM arguments 4 54
For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Suggested Courses

738 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