|
[Date Index]
[Thread Index]
[Author Index]
Re: Using sockets for "downloader" application in Mathematica
- To: mathgroup at smc.vnet.net
- Subject: [mg64333] Re: Using sockets for "downloader" application in Mathematica
- From: bghiggins at ucdavis.edu
- Date: Sun, 12 Feb 2006 04:00:17 -0500 (EST)
- References: <dshfkb$hob$1@smc.vnet.net><dsk7tg$i23$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
John,
If I recall correctly I had problems using the code in GetURL.nb. I
found that the modified version by Mertig called OpenURL worked fine.
Here is the reference:
http://www.mertig.com/jlink/
The code I tried out (based on Mertig) and worked is given below:
In[1]:=
Needs["JLink`"];
In[2]:=
ImportURL[url_String] :=JavaBlock[
Module[{u, s="", stream, numRead, buf},
InstallJava[];
u =
JavaNew["java.net.URL", url];
stream =
u@openStream[];
If[stream ===
$Failed,Return[$Failed]];
buf =
JavaNew["[B", 5000]; (* 5000 is an \arbitrary buffer
size.*)
While[(numRead =
stream@read[buf]) > 0,
s =
(s<>FromCharacterCode[(If[#<0,#+256,#]&)/@
Take[Val[buf],numRead]])]
stream@close[];
s]];
ImportURL["http://www.higgins.ucdavis.edu"]
Cheers,
Brian
Prev by Date:
Re: newbie want to join the group
Next by Date:
Re: newbie want to join the group
Previous by thread:
Re: Using sockets for "downloader" application in Mathematica
Next by thread:
mathematica problems with nautilus
|