#!/home/markt/usr/local/Linux/bin/perl -w
use strict;
no strict 'subs';
use Java;

###
# A long and arduous way to fetch & display a web page!
###

print "Gimmie the full URL of a page for me to fetch: (http://www.zzo.com) ";
my $page = <STDIN>;
chomp $page;
$page ||= "http://www.zzo.com";
my $java = new Java();

# This'll return a stream...
my $object = $java->create_object("java.net.URL",$page)->openConnection->getContent;

my $array = $java->create_array("byte",5000);
my $v = $array->get_value;
print "ARRAY: $v\n";

# Read into entire byte array 
my $back = $object->read($array);
my $val = $back->get_value;
print "got back $val chars\n";

my $len = $array->get_length;
print "array length $len bytes\n";
for (my $i = 0; $i < $val; $i++)
{
	print chr($array->get_field($i)->get_value);
}

my $a2 = $java->create_array("double",630);
for (my $i = 0, my $index = 0; $i < 2*3.14159; $i += .01, $index++)
{
	print "Setting $index to $i\n";
	$a2->set_field($index,"$i:double");
}
for (my $index = 0; $index < 630; $index++)
{
	my $val = $a2->get_field($index)->get_value;
	print "Float value $index: $val\n";
}
