Thanks fry,
I read faq, I think the security problem is:
Applets may only connect to servers other than the one from which they came. If you need to redirect things from another server, you can write a short script that will do it, understanding the possible security consequences for your own machine.
But now I try the sketch read a php file which read data from other server. And It following with out read nothing. I'm wondering if I understand well the java security issue.
PHP script(called "extractor.php")
Code:
<?php
$mifichero = "http://es.old.finance.yahoo.com/d/quotes.csv?s=ELE.MC&f=sl1d1t1c1ohgv&e=.csv";
if ($mi_array=file($mifichero)) {
while (list ($linea, $contenido) = each ($mi_array)) {
echo $contenido;
}
}
?>
Sketch in processing:
Code:
BufferedReader reader;
String csvString,name, joker;
float dayChange;
void setup(){
feed();
coloring();
}
void feed(){
try {
println("getting started...");
reader = reader("extractor.php");
println("got reader...");
String line = null;
// read lines one at a time
if((line = reader.readLine()) != null) {
println(line);
csvString = line;
}
println("done reading.");
StringTokenizer tokenizer = new StringTokenizer(csvString, ",");
name = tokenizer.nextToken();// println("tradeDate : "+tradeDate );
joker = tokenizer.nextToken();
joker = tokenizer.nextToken();
joker = tokenizer.nextToken();
try{
dayChange = Float.parseFloat(tokenizer.nextToken());
println("day Change ->"+dayChange);
}
catch(NumberFormatException e) {
}
}
catch (IOException e) {
e.printStackTrace();
}
}
void coloring(){
int r,g,b;
if (dayChange!=0.0){
if (dayChange < 0.0){r= (int)Math.abs(255.0*dayChange);}else{r=0;};
if (dayChange > 0.0){g= (int)(255.0*dayChange);}else{g=0;};
b=0;
background(r,g,b);
}else{
background(255,255,255);
}
}
It's in the same place:
http://www.derivart.info/visualizaciones/index_background/Mar