FAQ
Cover
This is the archive Discourse for the Processing (ALPHA) software.
Please visit the new Processing forum for current information.

   Processing 1.0 _ALPHA_
   Bugs
   Bug Fixes, Implemented Suggestions
(Moderator: fry)
   loading Strings from URL
« Previous topic | Next topic »

Pages: 1 
   Author  Topic: loading Strings from URL  (Read 769 times)
Hannes

WWW
loading Strings from URL
« on: Jun 6th, 2004, 9:56pm »

Hi,
 
please try this for example:
1. write a silly little sketch with a loadStrings() Function which is loading a String from an URL.
 
2. please include now some external classes to the project and you will see after you created a code-folder (with or without any files into it) the loadString() fails with an error like this:
 
problem loading strings from http://www.xyz.de/myscript
 
java.net.ConnectException: Connection timed out: connect at java.net.PlainSocketImpl.socketConnect(Native Method)
 at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:305)
 at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:171)
 at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:15
 
First I thought it was only a sonia-problem (which i want to include) but this happens also if there is an empty code-folder or a code-folder with other code into it...
 
looking forward,
hannes
 

Everything is possible ... just try it!
fry


WWW
Re: loading Strings from URL
« Reply #1 on: Jun 11th, 2004, 6:47pm »

hm, i just tried it and couldn't get it to replicate. i used:
 
Code:
String stuff[] = loadStrings("http://processing.org/download/bugs.txt");
for (int i = 0; i < stuff.length; i++) {
  println(stuff[i]);
}

and it was ok with/without a code folder and with/without stuff actually in the code folder (using rev 69, and it appeared to be the same on 6.  
 
any ideas on what else might be triggering it (i don't doubt there's a bug, i just need to figure out how to replicate)
 
Hannes

WWW
Re: loading Strings from URL
« Reply #2 on: Jun 11th, 2004, 7:22pm »

Hi ben,
 
I just copied your example above and without code-folder it works well - but if I create a code-folder it doesn't run.  
 
I'm using V-0069 Alpha on WinXP
 
bye,
hannes
 

Everything is possible ... just try it!
fry


WWW
Re: loading Strings from URL
« Reply #3 on: Jun 12th, 2004, 3:58am »

are you using standard or expert?
 
Hannes

WWW
Re: loading Strings from URL
« Reply #4 on: Jun 12th, 2004, 10:30am »

Hi ben,
 
I'm already using the standard version.
 
I just downloaded the expert-version to see if there is a difference. ...but NO, there is also the same output. Only without 'code' folder it runs ...
 
Til now i'm not a real Java geek so please tell me if there is an alternative for using the loadStrings() function. Without loading Data from an URL (i need also a code-folder) i can't go on with my little sketch idea ...
 
looking forward,
hannes
 
« Last Edit: Jun 12th, 2004, 4:43pm by Hannes »  

Everything is possible ... just try it!
fry


WWW
Re: loading Strings from URL
« Reply #5 on: Jun 14th, 2004, 8:02pm »

see if this works, doing it by hand:
 
try {
  URL url = new   URL("http://processing.org/download/bugs.txt");
  InputStream stream = url.openStream();
  String lines[] = loadStrings(stream);
 
} catch (IOException e) {
  e.printStackTrace();
}
 
if not, here's the code to loadStrings, which might help too:
Code:
 static public String[] loadStrings(InputStream input) {
    try {
 BufferedReader reader =  
   new BufferedReader(new InputStreamReader(input));
 
 String lines[] = new String[100];
 int lineCount = 0;
 String line = null;
 while ((line = reader.readLine()) != null) {
   if (lineCount == lines.length) {
     String temp[] = new String[lineCount << 1];
     System.arraycopy(lines, 0, temp, 0, lineCount);
     lines = temp;
   }
   lines[lineCount++] = line;
 }
 reader.close();
 
 if (lineCount == lines.length) {
   return lines;
 }
 
 // resize array to appropraite amount for these lines
 String output[] = new String[lineCount];
 System.arraycopy(lines, 0, output, 0, lineCount);
 return output;
 
    } catch (IOException e) {
 e.printStackTrace();
    }
    return null;
  }
 
Hannes

WWW
Re: loading Strings from URL
« Reply #6 on: Jun 14th, 2004, 9:08pm »

Hi ben,
 
first of all many thanks for your help!  
 
It is funny, i tried your 'by hand' example and it is the same. With code-folder there comes now this exception:
java.net.ConnectException: Connection timed out: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:305)
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:171)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:15
at java.net.Socket.connect(Socket.java:426)
 
Now i start trying your second example ...
 
bye,
hannes
 

Everything is possible ... just try it!
Hannes

WWW
Re: loading Strings from URL
« Reply #7 on: Jun 14th, 2004, 9:23pm »

Oh, it seems for me that if i use a code folder i cannot get Data from any URL. I tried your second example and it runs well, but with a code-folder it throws out the same 'timeout'-exception...
 
 

Everything is possible ... just try it!
fry


WWW
Re: loading Strings from URL
« Reply #8 on: Jun 15th, 2004, 3:38am »

weird..  
 
do you have virus scanning/prevention software enabled, specifically norton antivirus?
 
i wonder if we're running into that sort of bug here..
 
Hannes

WWW
Re: loading Strings from URL
« Reply #9 on: Jun 15th, 2004, 10:00am »

Hey, you are so good ...
 
this question solves it all. I'm using the freeware version of the
outpost-firewall from agnitum, and after switching it off
i am able to load any URL-Data with a code-folder into my project...
 
I think there is a bug into the outpost software, or  
does Java uses with / without code-folder a different security-level?
But why does outpost not ask me for enabling such kind of traffic?
 
many thanks for your help!
hannes
 

Everything is possible ... just try it!
Hannes

WWW
Re: loading Strings from URL
« Reply #10 on: Jun 15th, 2004, 10:22am »

It is a little bit strange with this firewall:
 
if I set the JAVAW.EXE as an 'ever trusted' application then i cannot loadStrings (+code-folder)
 
but if i remove this entry so outpost asks me at every start of JAVAW.EXE and if i click on 'trust once' - it works ...
 
I think it's time to get a new firewall ...
 

Everything is possible ... just try it!
Hannes

WWW
Re: loading Strings from URL
« Reply #11 on: Jun 15th, 2004, 6:52pm »

Hey ben,
 
now i've got a different firewall and i found something interesting:
 
if i use the loadString() without code folder the firewall asks me to allow '\java\bin\javaw.exe'
and if there is a code folder it asks for '\java\bin\java.exe'
 
OK, now it works fine! And we know the difference...
 
best regards,
hannes
 

Everything is possible ... just try it!
Pages: 1 

« Previous topic | Next topic »