[3347] in java-interest

home help back first fref pref prev next nref lref last post

problem with URLConnection/InputStreams

daemon@ATHENA.MIT.EDU (Edd Dumbill)
Wed Nov 8 13:35:15 1995

Date: Wed, 8 Nov 1995 14:19:38 +0000 (GMT)
From: Edd Dumbill <edmundd@compnews.co.uk>
To: java-interest@java.sun.com
In-Reply-To: <Pine.SUN.3.91.951106162314.10060E-100000@Xenon.Stanford.EDU>


Hi,

I'm using the JDK beta.

I've written an applet which makes a connection to a URL to read a string 
from a file and then scroll it along. I use the following code to get the
string in:

	try {
	    uc = url.openConnection();
	    if (uc != null)
	      {
		uc.setUseCaches(true);
		uc.connect();
		is = uc.getInputStream();
		int av = is.available();
		System.out.println(av);
		if (av>0) {
		  byte inar[] = new byte[av];
		  
		  av = is.read(inar);
		  inar[av-1]=0; 
		  stxt = new String(inar,0);
		}
		is.close();
	      }
	  } catch (IOException e) {
	    e.printStackTrace();  }

The problem is that it works fine (most of the time - it has failed 
first time) , but then if I clone the  applet from the appletviewer, the 
clone returns 0 from is.available(). The httpd access log shows that the
information is being sent OK.

So what am I doing wrong?

Thanks for your help.

Edd.

      Edd Dumbill - Software Engineer - PA Data Design - +44 1430 488224
    mailto:edmundd@padd.press.net - http://www.pa.press.net/people/edmundd
      and i like the way you're broken and i'll like you when you're old

-
This message was sent to the java-interest mailing list
Info: send 'help' to java-interest-request@java.sun.com

home help back first fref pref prev next nref lref last post