Main Topics
Browse All TopicsHi. I need a function that does the following:
public static File getFileObjectFromURL(URL url) {
f = new File();
//get File Object from URL
.
.
.
return f;
}
This function is going to be used in an applet so there can be no writing of files or creating temporary files on a local machine. I've trolled the internet for days on this one . . . good luck!
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
that returns a string - not a File Object
http://java.sun.com/j2se/1
Thanks for the clarification ksivanath.
So, if i have an *applet* running on www.whatever.com, trying to create a File object from www.whatever.com/images/th
Also
>>So, if i have an *applet* running on www.whatever.com
the applet won't be running there (probably). The applet runs on the machine of whomever's looking at it
CEHJ:
Objective: Metaphile (http://sourceforge.net/pr
CEHJ:
(sorry, you're right, the applet isn't "running on" www.whatever.com - it was launched from there (or whatever the appropriate vocabulary is). anyway, the project involves reading metadata, using metaphile, in an applet environment.)
>>getClass().getResourceAs
CEHJ, I think, the asker is using a openesourced java called metafile which reads metadata from image file if you pass the image as File instasnce to them... in such case, this is not appropriate. your code will be useful if he has a file in the jar and want to read!
the metadata is embedded in the image . . . does that make a difference? i've attached a file if you'd like to try. the XMP metadata is as follows:
- CopyrightNotice: 2006
- Keywords: book, Senior Library 2006, bird, orange
- Document Title: To Kill a Mockingbird
- Author: Richard Smith
- Description: To Kill a Mockingbird book cover
if you dl the image and open it in photoshop you get something like the attached image. getting at this data is no simple task, hence rather robust libraries like metaphile. all images in www.whatever.com/images contain embedded metadata, which i need to access through an applet . . . and metaphile only takes File objects . . .
Sourceforge project: http://sourceforge.net/pro
code examples: http://www.miniturismo.co.
- also see (on the same site) example02.php, example03.php, example04.php, example05.php
from http://java.sun.com/sfaq/#
unless i'm missing something:
What are applets prevented from doing?
In general, applets loaded over the net are prevented from reading and writing files on the client file system, and from making network connections except to the originating host.
How do I let an applet write a file?
Applets loaded into a Java-enabled browser can't write files.
I suppose all this prevents me from getting access to a File object . . .
all you have to sign the applet jar files and the client user has to accept the certificate while running the applet!
here is how you sign the applet,
http://www.doc.ic.ac.uk/cs
here is a complete glossary of signed applet...
http://mindprod.com/jgloss
CEHJ:
i've managed to track down the source in a CVS repository off sourceforge. here's the constructor i'd need to change - any ideas?
public JpegFile(File f) throws IOException, JpegException {
try {
this.file = f;
fileLog.log(Level.INFO, "Creating JpegFile based on file " + f.getAbsolutePath());
fileStream = new BufferedInputStream(new FileInputStream(file));
this.loadHeader();
} finally {
if (fileStream != null) {
fileStream.close();
}
}
}
Business Accounts
Answer for Membership
by: CEHJPosted on 2008-04-10 at 08:47:38ID: 21326091
URL.getFile