Advertisement

04.10.2008 at 08:44AM PDT, ID: 23312221
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

Java: Create a File Object from URL (without downloading)

Tags: Java
Hi.  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!
Start your free trial to view this solution
Question Stats
Zone: Software
Question Asked By: noblends
Solution Provided By: ksivananth
Participating Experts: 2
Solution Grade: A
Views: 79
Translate:
Loading Advertisement...
04.10.2008 at 08:47AM PDT, ID: 21326091

Rank: Genius

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
04.10.2008 at 08:48AM PDT, ID: 21326102

Rank: Genius

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
04.10.2008 at 08:49AM PDT, ID: 21326115

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
04.10.2008 at 08:52AM PDT, ID: 21326148

Rank: Sage

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
04.10.2008 at 08:59AM PDT, ID: 21326235

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
04.10.2008 at 09:01AM PDT, ID: 21326258

Rank: Genius

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
04.10.2008 at 09:02AM PDT, ID: 21326263

Rank: Sage

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
04.10.2008 at 09:02AM PDT, ID: 21326270

Rank: Sage

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
04.10.2008 at 09:04AM PDT, ID: 21326298

Rank: Genius

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
04.10.2008 at 09:07AM PDT, ID: 21326321

Rank: Genius

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
04.10.2008 at 09:10AM PDT, ID: 21326358

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
04.10.2008 at 09:13AM PDT, ID: 21326385

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
04.10.2008 at 09:17AM PDT, ID: 21326443

Rank: Genius

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
04.10.2008 at 09:18AM PDT, ID: 21326465

Rank: Genius

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
04.10.2008 at 09:26AM PDT, ID: 21326559

Rank: Sage

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
04.10.2008 at 09:29AM PDT, ID: 21326590

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
04.10.2008 at 09:35AM PDT, ID: 21326674

Rank: Genius

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
04.10.2008 at 09:35AM PDT, ID: 21326680

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
04.10.2008 at 09:42AM PDT, ID: 21326765

Rank: Genius

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
04.10.2008 at 09:47AM PDT, ID: 21326808

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
04.10.2008 at 10:15AM PDT, ID: 21327098

Rank: Genius

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
04.10.2008 at 10:36AM PDT, ID: 21327350

Rank: Sage

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
04.10.2008 at 10:47AM PDT, ID: 21327437

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
04.10.2008 at 10:52AM PDT, ID: 21327472

Rank: Sage

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
04.10.2008 at 10:55AM PDT, ID: 21327496

Rank: Sage

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
04.10.2008 at 10:57AM PDT, ID: 21327519

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
04.10.2008 at 11:00AM PDT, ID: 21327551

Rank: Sage

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
04.10.2008 at 11:02AM PDT, ID: 21327571

Rank: Sage

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
04.10.2008 at 11:04AM PDT, ID: 21327601

Rank: Genius

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
Loading Advertisement...
Microsoft
  • Internet Protocols
  • Applications
  • Development
  • OS
  • Hardware
  • Windows Security
Apple
  • Operating Systems
  • Hardware
  • Programming
  • Networking
  • Software
Internet
  • Search Engines
  • File Sharing
  • WebTrends / Stats
  • Spy / Ad Blockers
  • Web Browsers
  • New Net Users
  • Web Development
  • Chat / IM
  • Anti Spam
  • Web Servers
  • Anti-Virus
  • Email Clients
Gamers
  • Tips
  • Online / MMORPG
  • Puzzle
  • Emulators
  • Action / Adventure
  • Role Playing
  • Consoles
  • Game Programming
  • Strategy
  • Sports
  • Misc
  • Computer Games
Digital Living
  • Hardware
  • New Net Users
  • New Users
  • Software
  • Digital Music
  • Gaming World
  • Home Security
  • Apple
  • Networking Hardware
Virus & Spyware
  • Vulnerabilities
  • IDS
  • Encryption
  • Anti-Virus
  • Operating Systems Security
  • Software Firewalls
  • WebApplications
  • Cell Phones
  • Operating Systems
  • Internet
  • Hardware Firewalls
Hardware
  • Handhelds / PDAs
  • Displays / Monitors
  • Components
  • Networking Hardware
  • Peripherals
  • Laptops/Notebooks
  • Storage
  • Servers
  • Desktops
  • New Users
  • Misc
  • Apple
Software
  • System Utilities
  • Industry Specific
  • Network Management
  • Photos / Graphics
  • Page Layout
  • VMWare
  • Misc
  • Web Development
  • OS
  • CYGWIN
  • Voice Recognition
  • Message Queue
  • Quality Assurance
  • Security
  • Firewalls
  • MultiMedia Applications
  • Development
  • Database
  • Office / Productivity
  • Business Management
  • OS/2 Apps
  • Server Software
  • Internet / Email
ITPro
  • OS
  • Storage
  • Encryption
  • Operating Systems Security
  • Apple Hardware
  • Laptops & Notebooks
  • Servers
  • Networking Hardware
  • Peripherals
  • Devices
  • Displays / Monitors
  • WebTrends / Stats
  • Search Engines
  • Firewalls
  • WebApplications
  • IDS
  • Vulnerabilities
  • Email Clients
  • File Sharing
  • Spy / Ad Blockers
  • Web Browsers
  • Web Servers
  • Networking
  • Anti-Virus
  • Chat / IM
  • Anti Spam
Developer
  • Web Servers
  • Web Browsers
  • Game Programming
  • Dev Tools
  • Industry Specific
  • Office / Productivity
  • Database
  • CYGWIN
  • Web Development
  • Search Engines
  • File Sharing
  • WebTrends / Stats
  • Programming
  • Content Management
  • Application Servers
  • Protocols
Storage
  • Removable Backup Media
  • Storage Technology
  • Servers
  • Grid
  • Remote Access
  • Backup / Restore
  • Misc
  • Hard Drives
OS
  • Miscellaneous
  • Security
  • Development
  • Linux
  • VMWare
  • MainFrame OS
  • Unix
  • Apple
  • OS / 2
  • AS / 400
  • BeOS
  • Microsoft
  • VMS / OpenVMS
Database
  • Oracle
  • Miscellaneous
  • MySQL
  • Software
  • Sybase
  • Contact Management
  • PostgreSQL
  • Data Manipulation
  • Clarion
  • InterSystems Cache
  • Siebel
  • MUMPS
  • OLAP
  • SQLBase
  • SAS
  • GIS & GPS
  • 4GL
  • Berkeley DB
  • DB2
  • Informix
  • Interbase / Firebird
  • FoxPro
  • Reporting
  • LDAP
  • Filemaker Pro
  • MS SQL Server
  • dBase
  • MS Access
Security
  • Misc
  • Web Browsers
  • Software Firewalls
  • Operating Systems Security
  • File Sharing
  • Spy / Ad Blockers
  • Vulnerabilities
  • WebApplications
  • IDS
  • Anti-Virus
  • Encryption
  • Anti Spam
  • Email Clients
  • VPN
  • Chat / IM
Programming
  • Editors IDEs
  • Installation
  • Handhelds / PDAs
  • Multimedia Programming
  • System / Kernel
  • Algorithms
  • Game
  • Signal Processing
  • Project Management
  • Open Source
  • Database
  • Misc
  • Languages
  • Processor Platforms
  • Theory
Web Development
  • Scripting
  • Blogs
  • Web Servers
  • Software
  • Search Engines
  • Web Graphics
  • Images
  • Internet Marketing
  • Images and Photos
  • Components
  • Document Imaging
  • Web Languages/Standards
  • Illustration
  • WebApplications
  • Fonts
  • WebTrends / Stats
  • Authoring
  • Digital Camera Software
  • Miscellaneous
Networking
  • Protocols
  • Apple Networking
  • Network Management
  • Message Queue
  • Application Servers
  • Content Management
  • File Servers
  • Email Servers
  • Misc
  • Java Editors & IDEs
  • Wireless
  • Networking Hardware
  • Backup / Restore
  • System Utilities
  • ISPs & Hosting
  • Web Servers
  • Storage Technology
  • Removable Backup Media
  • Servers
  • Broadband
  • Grid
  • OS / 2
  • Novell Netware
  • Unix Networking
  • Windows Networking
  • Security
  • Telecommunications
  • Operating Systems
  • Linux Networking
Other
  • Community Advisor
  • Lounge
  • Community Support
  • New Net Users
  • Philosophy / Religion
  • Math / Science
  • Miscellaneous
  • URLs
  • Expert Lounge
  • Politics
  • Puzzles / Riddles
Community Support
  • Suggestions
  • New to EE
  • New Topics
  • Community Advisor
  • CleanUp
  • Announcements
  • General
  • Feedback
  • Input
  • EE Bugs
 
04.10.2008 at 08:47AM PDT, ID: 21326091

Rank: Genius

URL.getFile
 
04.10.2008 at 08:48AM PDT, ID: 21326102
 
04.10.2008 at 08:49AM PDT, ID: 21326115
that returns a string - not a File Object

http://java.sun.com/j2se/1.4.2/docs/api/java/net/URL.html
 
04.10.2008 at 08:52AM PDT, ID: 21326148

Rank: Sage

File is a reference of the resource in the local file system and URL is a reference of a resource in remote or local system. So you will be able to create URL from File but the reverse is not possible unless you write the URL resource locally and then create File reference of it!
 
04.10.2008 at 08:59AM PDT, ID: 21326235
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/thisImage.jpg - this isn't possible?

 
04.10.2008 at 09:01AM PDT, ID: 21326258

Rank: Genius

>>that returns a string - not a File Object

Well only a String is meaningful. The file(File) resides elsewhere.

What is your objective?
 
04.10.2008 at 09:02AM PDT, ID: 21326263

Rank: Sage

nope, u need to write that locally and then refer it as File!
 
04.10.2008 at 09:02AM PDT, ID: 21326270

Rank: Sage

locally  --> local disk!
 
04.10.2008 at 09:04AM PDT, ID: 21326298

Rank: Genius

>>trying to create a File object from ...

Why do you *want* to create a File object?
 
04.10.2008 at 09:07AM PDT, ID: 21326321

Rank: Genius

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
 
04.10.2008 at 09:10AM PDT, ID: 21326358
CEHJ:

Objective: Metaphile (http://sourceforge.net/projects/metaphile) is a Java package that basically reads metadata from image files.  It requires a File object.  I want to use it in a web-based environment, in an applet.  All images are "local" - local to the server where the applet was launched.  like i wrote earlier, if the applet is running on www.whatever.com, all images are in www.whatever.com/images.  I need to pass it a File object from within an applet . . .
 
04.10.2008 at 09:13AM PDT, ID: 21326385
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.)
 
04.10.2008 at 09:17AM PDT, ID: 21326443

Rank: Genius

Reading metadata from a remote URL is a piece of cake if that's what you want to do...
 
04.10.2008 at 09:18AM PDT, ID: 21326465

Rank: Genius

... and you can do that without using a file e.g.
1:
InputStream metaDataIn = getClass().getResourceAsStream("metadata.xml");
Open in New Window
 
04.10.2008 at 09:26AM PDT, ID: 21326559

Rank: Sage

>>getClass().getResourceAsStream("metadata.xml");

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!
 
04.10.2008 at 09:29AM PDT, ID: 21326590
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
 
JPG with embedded XMP metadata
JPG with embedded XMP metadata
 
 
04.10.2008 at 09:35AM PDT, ID: 21326674

Rank: Genius

Just get the stream as i mentioned and you'll be able to get the contents, including this sort of stuff:
1:
2:
3:
4:
5:
6:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
        <key>com.apple.print.PageFormat.PMHorizontalRes</key>
................................................
Open in New Window
 
04.10.2008 at 09:35AM PDT, ID: 21326680
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 . . .
 
Metadata for test.jpg
Metadata for test.jpg
 
 
04.10.2008 at 09:42AM PDT, ID: 21326765

Rank: Genius

>>and metaphile only takes File objects

Unfortunate and bad design. Do you have a link to this API?
 
04.10.2008 at 09:47AM PDT, ID: 21326808
Sourceforge project: http://sourceforge.net/projects/metaphile

code examples: http://www.miniturismo.co.uk/metaphile/example01.php
     - also see (on the same site) example02.php, example03.php, example04.php, example05.php


 
04.10.2008 at 10:15AM PDT, ID: 21327098

Rank: Genius

Since they haven't seen fit to give you an InputStream ctor, you'll have to create a temporary file. Web Start would be less strict than an applet.

If you can get hold of the source (can't see it there) you can fix it easily enough. Or get them to do it ;-)
 
04.10.2008 at 10:36AM PDT, ID: 21327350

Rank: Sage

whats the problem for you to write the file locally from applet?
 
04.10.2008 at 10:47AM PDT, ID: 21327437
from http://java.sun.com/sfaq/#read

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 . . .
 
04.10.2008 at 10:52AM PDT, ID: 21327472