[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

URL-problems!

Posted on 1997-08-19
2
Medium Priority
?
275 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
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 learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
Suggested Courses
Course of the Month18 days, 5 hours left to enroll

831 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