I can't make is "self contained" as I don't own de jar in wich
"loadmap()" resides. The server is intranet so that won't help either.
The problem is that i don't know if
con.getInputStream() results in the same datatype as
FileInputStream("myfile")
URL url = new URL("http://www.mysite/myfile");
URLConnection con = url.openConnection();
con.connect();
InputStream urlfs;
urlfs = con.getInputStream();
Billy wrote:
> try {
> URL url = new URL("http://www.mysite/myfile");
'404' in 'mybrowser', but.. is your server treating it as a directory?
> try {
> URLConnection con = url.openConnection();
[quoted text clipped - 4 lines]
> } catch (IOException e) {System.out.println(e);}
> } catch (MalformedURLException e) {System.out.println(e);}
And what, exactly are you doing with the
'java.net.UnknownHostException's?
No, don't tell me, let the (short, complete) code do the talking.
<http://www.physci.org/codes/sscce.jsp>
Andrew Thompson - 14 Oct 2005 09:16 GMT
> I can't make is "self contained" as I don't own de jar in wich
> "loadmap()" resides.
Use a 'dummy' jar.
> The server is intranet so that won't help either.
Move it (the page, not the intranet)
> The problem ..
No problems, just challenges.
HTH
Chris Smith - 14 Oct 2005 16:50 GMT
> I can't make is "self contained" as I don't own de jar in wich
> "loadmap()" resides. The server is intranet so that won't help either.
That is a shame. My first guess is that the problem is in loadmap().
Since it apparently works when the data is immediately available, but
not when you need to wait for a connection over a network, my guess is
that the person writing the loadmap() function is misusing the
available() method.
Try this code, and let us know if it fixes anything. Exception handling
removed for clarity.
URL url = new URL("http://www.mysite/myfile");
URLConnection con = url.openConnection();
con.connect();
InputStream urlfs = con.getInputStream();
ByteArrayOutputStream out = new ByteArrayOutputStream();
int c;
while ((c = urlfs.read()) != -1) out.write((byte) c);
urlfs.close();
return loadmap (new ByteArrayInputStream(out.toByteArray());
Not that you should put the code into production without thinking
through the consequences... but just let us know if it works.

Signature
www.designacourse.com
The Easiest Way To Train Anyone... Anywhere.
Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
Billy - 25 Oct 2005 18:22 GMT
> URL url = new URL("http://www.mysite/myfile");
> URLConnection con = url.openConnection();
[quoted text clipped - 5 lines]
> urlfs.close();
> return loadmap (new ByteArrayInputStream(out.toByteArray());
out.size() gives a positive value, so I already got rid of the
java.lang.NegativeArraySizeException
Also the available() method was missing, so that has been solved (after
lots of negociating:-))
Roedy Green - 15 Oct 2005 04:25 GMT
>The problem is that i don't know if
>con.getInputStream() results in the same datatype as
>FileInputStream("myfile")
They DON'T result in the same type. You can find that out by dumping
inputstream.getClass()
But they DO both implement InputStream.

Signature
Canadian Mind Products, Roedy Green.
http://mindprod.com Again taking new Java programming contracts.