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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Suggested Courses
Course of the Month10 days, 8 hours left to enroll

765 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