Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

reading a file from a url

 
naveen yadav
Ranch Hand
Posts: 384
Java MyEclipse IDE Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi ranchers,

i have this question that suppose there is a site called myVideos.com just like youtube .Is that possible create a java networking program to
get the reference of video files and read them ?

 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
naveen yadav wrote:i have this question that suppose there is a site called myVideos.com just like youtube .Is that possible create a java networking program to
get the reference of video files and read them ?


Yes.
 
naveen yadav
Ranch Hand
Posts: 384
Java MyEclipse IDE Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have written a small java program which copies the code of a web page
have a look.





please suggest few hints how to go about .thanks for reply

 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
naveen yadav wrote:
please suggest few hints how to go about .thanks for reply


What specific problems are you having?
 
naveen yadav
Ranch Hand
Posts: 384
Java MyEclipse IDE Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how to get the videos file link form xyz.com? Suppose http://www.youtube.com/watch?v=3POGRbSUPtY" is a link to a video file and when i hit this url it plays the video.
how should i can read this file ?
 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
naveen yadav wrote:how to get the videos file link form xyz.com? Suppose http://www.youtube.com/watch?v=3POGRbSUPtY" is a link to a video file and when i hit this url it plays the video.
how should i can read this file ?


Yes, I know that this is what you're trying to do. And I see that you've posted code that shows that you have at least some idea how to go about doing that. Now I am asking you what specific problems you are having.
 
Paul Clapham
Sheriff
Pie
Posts: 20959
31
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I really wouldn't expect anybody to hack YouTube on the first try. But at any rate I'm pretty sure that YouTube's terms of service don't permit you to just download videos from them. I suggest you should read a site's terms of service before you start trying to download files from that site, and bear in mind that we can't help you to perform acts which might be considered as illegal or piracy on this forum.
 
Pat Farrell
Rancher
Posts: 4678
7
Linux Mac OS X VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And *after* you have found that its allowable to download the files, why would you want to write code to do it? Use code or programs that someone else has written that are debugged, documented, and tested.

To fetch the contents of a URL, I"d just use wget or curl.

If, for some weird reason, I needed to do it totally within Java, I'd use the Apache HTTP client library.

There is a huge difference between reading a URL's file once, and doing it reliably in production.


 
naveen yadav
Ranch Hand
Posts: 384
Java MyEclipse IDE Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i was trying to develop a downloader application from which one can download videos files. There are various applications to do that.
The reason for doing that is i am learning the java networking from quite some time and thought to do some "practical things "
 
Pat Farrell
Rancher
Posts: 4678
7
Linux Mac OS X VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You may desire to learn some Java networking, but after you have the initial version working, you will spend most of your effort reading RFCs to implement the full protocol.

Rather than doing that, I strongly recommend switching to a pre-existing library
 
naveen yadav
Ranch Hand
Posts: 384
Java MyEclipse IDE Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Pat Farrel wrote:I strongly recommend switching to a pre-existing library


are talking of Apache HTTP client library ?

Pat Farrel wrote:
you will spend most of your effort reading RFCs to implement the full protocol.


and how RFC will help me out ?
 
Paul Clapham
Sheriff
Pie
Posts: 20959
31
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
naveen yadav wrote:i was trying to develop a downloader application from which one can download videos files. There are various applications to do that.
The reason for doing that is i am learning the java networking from quite some time and thought to do some "practical things "


Sure. Learning by doing is an excellent idea. I'm just recommending you do the right things. Like if you were training to become a locksmith, testing your skills by breaking into banks would be the wrong way to go about it.
 
naveen yadav
Ranch Hand
Posts: 384
Java MyEclipse IDE Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul Clapham wrote:
Sure. Learning by doing is an excellent idea. I'm just recommending you do the right things. Like if you were training to become a locksmith, testing your skills by breaking into banks would be the wrong way to go about it.


well said Paul.
i would appreciate if you can guide me .I am currently reading book Java Network Programming, 3rd Edition, 2004By Elliotte Rusty Harold and java networking tutorial and side by side want to do some practical exercises.
 
Pat Farrell
Rancher
Posts: 4678
7
Linux Mac OS X VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
naveen yadav wrote:
Pat Farrel wrote:I strongly recommend switching to a pre-existing library


are talking of Apache HTTP client library ?


Yes, that is one. There are others.

The point is that making a proper HTTP client is complex and has subtleties that are likely to be missed the first dozen times you try.

You will be reinventing the wheel.
naveen yadav wrote:
Pat Farrel wrote:
you will spend most of your effort reading RFCs to implement the full protocol.


and how RFC will help me out ?


The RFCs define the protocols. You have to implement all of them (or all of the ones related to HTTP) to be able to say your code works.

I wrote my own, years ago before the Apache library was available. I had it in production for six months before it blew up. The data changed from the remote server, and I wasn't supporting the RFC fully.

Let me be clear: as a learning exercise, what you are trying to do is fine.
As a production application, its folly to try to write your own, and a huge waste of time.


#Edited to fix block quote
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic