Reading files from website

O

OldPro

I tried to read files (gif) off of various websites, and I got a
security error each time. I can easily copy them by hand to my
computer. Does Java not have the ability to copy or read files from
the internet?
 
A

Andrew Thompson

OldPro said:
I tried to read files (gif) off of various websites,

The internet is a big place. Care to name one
specific site/URL that fails for you?
..and I got a
security error each time. I can easily copy them by hand to my
computer. Does Java not have the ability to copy or read files from
the internet?

Sure it can. 'Image Fader JApplet'* is an app. that reads files
from its own web site, and two others (including mine).
* <http://www.knutejohnson.com/>
 
L

Lasse Reichstein Nielsen

OldPro said:
I tried to read files (gif) off of various websites, and I got a
security error each time.

Then you must be using a security manager that doesn't allow that.
Are your code running as an applet?
I can easily copy them by hand to my computer. Does Java not have
the ability to copy or read files from the internet?

Default Java, just running from the command line, can do pretty much
anything. You must either be running in a restricted environment or
manually set up a security manager to cause security exceptions.

/L
 
R

Roedy Green

I tried to read files (gif) off of various websites, and I got a
security error each time. I can easily copy them by hand to my
computer. Does Java not have the ability to copy or read files from
the internet?

see http://mindprod.com/jgloss/applet.html

Applets are not permitted to read from any server other than the one
they were loaded from unless they are signed.
 
A

Andreas Leitgeb

Maybe I missed some context, but if you get security errors,
doesn't that mean that your jvm is not trusting the class-file
that tries to download stuff. Is it an unsigned applet from
a webpage?
Or use the wget utility. Its been ported to most OSes.

If the applet(?) is denied access to foreign servers, it will
most likely be also denied permission to start external programs,
locally.
 
M

Martin Gregorie

Andreas said:
If the applet(?) is denied access to foreign servers, it will
most likely be also denied permission to start external programs,
locally.
The OP isn't using an applet. I just reviewed the thread to be certain.
He just asked why his (Java) program couldn't download some GIF images
from various websites.

wget can in general read anything that a browser can display, unless its
prevented by the content of a robots.txt file. OK, its got a shed-load
of options, but writing a script that uses it to go get some image files
has to be a lot quicker than writing a Java program to do the same job
even if you use the web access classes. That's why I suggested using it.
 
M

Martin Gregorie

Roedy said:
see http://mindprod.com/jgloss/applet.html

Applets are not permitted to read from any server other than the one
they were loaded from unless they are signed.
>
The OP didn't mention applets. He also doesn't say whether he's using
the web-related standard classes but if he is, could he be getting
blocked by robots.txt? I had a quick scan of documentation for likely
classes but couldn't find anything that says whether robots.txt is
honored or ignored.
 
G

Gordon Beaton

The OP didn't mention applets. He also doesn't say whether he's
using the web-related standard classes but if he is, could he be
getting blocked by robots.txt? I had a quick scan of documentation
for likely classes but couldn't find anything that says whether
robots.txt is honored or ignored.

I can't imagine why the web-related standard classes should silently
read and obey robots.txt on behalf of every possible client
application that uses them. Certainly not every java program is a web
crawler, and anyway robots.txt is just advisory.

/gordon

--
 
G

Gordon Beaton

wget can in general read anything that a browser can display, unless
its prevented by the content of a robots.txt file.

Wget can and will retrieve any document specifically requested,
regardless of robots.txt. However it *chooses* to obey robots.txt when
recursively retrieving large parts of websites (with "wget -r").

/gordon

--
 
M

Martin Gregorie

Gordon said:
I can't imagine why the web-related standard classes should silently
read and obey robots.txt on behalf of every possible client
application that uses them. Certainly not every java program is a web
crawler, and anyway robots.txt is just advisory.
I think you're right.

I just wanted to highlight the point that you can build web crawlers
with these classes in java.net and that many of these classes are among
the worst documented standard classes.

There is no java.net class I'm aware of that accesses or implements
robots.txt but if there was one it would need to be woven into this
package or applying the rules in this file could be, um, interesting.

I notice that the OP has been silent since his initial post. I for one
don't intend to say anything more unless/until he posts again with more
details or results.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,787
Messages
2,569,631
Members
45,340
Latest member
Thalia56P0

Latest Threads

Top