Solved

document loading from Mac browser

Posted on 1998-11-19
6
165 Views
Last Modified: 2010-03-30
I've written an applet that reads text from a file on the server.  The file is in the same directory as the applet.  I've verified that it's got the right filename and path.  However, no data is getting read in.  This applet works on win95 and NT in Netscape 3 and 4 and in IE3 and IE4.  It also works on UNIX, both SGI and Solaris.  However, it is currently failing on both Netscape 3 and 4 on the Macintosh.  This applet is running all 1.02 JDK code, and I tried compiling with both a 1.02 and 1.1.x compiler.  

In every case, no data is showing up.  Here's the snippet where I read in the data:

try {
  url = new URL(getCodeBase, "data");
  stream = url.openStream();
 
  is = new DataInputStream(stream);
 
  while (is.available() > 0) {
    v.addElement(is.readLine());
  }

-Tony
0
Comment
Question by:rembo
  • 3
  • 2
6 Comments
 
LVL 5

Expert Comment

by:fontaine
ID: 1227904
Just a remark. The way you are using the readLine() method of DataInputStream does not
seem correct to me. I would personally write the following:

String line = "";

while((line = is.readLine()) != null) {
    v.addElement(line);
}

Could you replace your current code by the one above and have a try?
0
 
LVL 6

Expert Comment

by:gadio
ID: 1227905
Tony, have you tried it on IE for mac? Also, on what stage does that code hanges? after the openStream? After the first readLine? Maybe the EOF is not tested correctly (as fontaine suggests).
0
 
LVL 4

Author Comment

by:rembo
ID: 1227906


Actually, fontaine's feedback fixed my problem.  It's really
strange though because, technically, my code is correct.  I
should be able to use the available() routine to determine
if I can read from the file or not, but it doesn't appear
to work on the Mac.  Fontaine, if you post a null message
as an answer, I'll be happy to give you the points.  

Thanks!

-Tony

0
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 
LVL 5

Accepted Solution

by:
fontaine earned 100 total points
ID: 1227907
:-)
0
 
LVL 6

Expert Comment

by:gadio
ID: 1227908
Tony, I think you might have a mistake there. You can't use the available() routine since its only indicating "the number of bytes that can be read from this input stream without blocking", so there can actually be more bytes to read from the file but not in the OS / VM buffer. You get to see this sort of bugs a lot when you move your code from one OS to another.
0
 
LVL 5

Expert Comment

by:fontaine
ID: 1227909
I agree with Gadio.  What probably happended is that there was nothing "ready to use"
when the loop was reached. Hence, nothing happended. The code I proposed works because readLine() is blocking until an EOL is reached.
0

Featured Post

ScreenConnect 6.0 Free Trial

Check out the updates in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI that improves session organization and overall user experience. See the enhancements for yourself!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Protect jar file - windows app 2 53
eclipse package explorer vs project explorer view 2 132
advertisement module in core php 4 162
Windows 10 IE Certificate Issue 10 45
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…
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 will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

773 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