Solved

URL-problems!

Posted on 1997-08-19
2
248 Views
Last Modified: 2012-06-21
Hi,

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?
0
Comment
Question by:atti
2 Comments
 
LVL 1

Accepted Solution

by:
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()
   {
      try{

      // 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?
M
0
 

Author Comment

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

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

Suggested Solutions

Title # Comments Views Activity
jar file executable 12 60
configure dependency in POM for new database 3 34
Adding multiple JVM environments to RedHat 6 7 49
Java class and jar 3 25
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

820 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