Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / First Aid / November 2006

Tip: Looking for answers? Try searching our database.

How to get file name from URL object

Thread view: 
carlbernardi@gmail.com - 05 Nov 2006 21:13 GMT
Hi,

I am trying to save web pages to file but sometimes the URL doesn't
have the file name with it as www.google.com doesn't for example.  In
this case I don't know how to get the file name of the web page since
it is not specified. If there is way to use the URL class or other
classes to get the URL to look like so http://www.google.com/index.html
then my problem would be solved.

Is there anyone here who can help me,

Thanks,

Carl
John W. Kennedy - 05 Nov 2006 21:33 GMT
> Hi,
>
[quoted text clipped - 4 lines]
> classes to get the URL to look like so http://www.google.com/index.html
> then my problem would be solved.

Not in general. If the server chooses to regard "/" as an adequate
resource name -- and most do --, there is nothing the client can do
about it.

Signature

John W. Kennedy
"The blind rulers of Logres
Nourished the land on a fallacy of rational virtue."
  -- Charles Williams.  "Taliessin through Logres: Prelude"

Oliver Wong - 06 Nov 2006 16:55 GMT
>> Hi,
>>
[quoted text clipped - 4 lines]
>> classes to get the URL to look like so http://www.google.com/index.html
>> then my problem would be solved.

   Just in case you didn't know, sometimes the contents of webpages come
from multiple files, and sometimes the contents of webpages don't come from
a file at all.

> Not in general. If the server chooses to regard "/" as an adequate
> resource name -- and most do --, there is nothing the client can do about
> it.

   Possible alternative designs include using heuristics (like what FireFox
does when you try to save a webpage), or somehow establishing a 1-to-1
correspondance between URLs and legal filenames, perhaps via some sort of
encoding process. For example, you might use base64 encoding so that the URL
"http://www.google.com/" is encoded to the filename
"aHR0cDovL3d3dy5nb29nbGUuY29tLw==.html".

   - Oliver


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.