• Post Reply Bookmark Topic Watch Topic
  • New Topic

Load Image or Movie files from URL & store the files to local directory  RSS feed

 
hezbaiyio
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

[ May 11, 2006: Message edited by: hezbai kebreab ]
 
Alexandru Popescu
Ranch Hand
Posts: 995
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am asking myself what does these really mean:
1/ Load image or movie files [...] to local directory
2/ [...] but I�m not able to store the image to my local directory.
3/ Though I�m able to load the file to the local directory, but I�m not able to view it.

:roll:

--
:alex |.::the_mindstorm::.
 
Horatio Westock
Ranch Hand
Posts: 221
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you look at your code carefully, you will see that you aren't actually downloading a the file. What you actually do is create a FileWriter and write the filename to it. You then create a FileOutputStream which overwrites that.

If you look at the file you create, you will see that it is completely empty.

Your code also contains some strange redundant lines like System.out.flush().

I think you need to start this project again from the start. Take each thing you want to acheive and write the code for, then test it. For example:

1. Write the code to take your command line arguments

2. Test your are getting the correct arguments using System.out.println()

3. Add the code to get a URLConnection to the resource, and get the meta-data about it: modified date, file name etc

4. Test you are able to create the connection and get the meta-data using System.out.println().

5. Add the code to download the content of the file from the server and write it to a local file. I suggest you search the web, and these forums for examples of how to do this.

6. Test your final program by trying a variety of different URLs and checking that you get the results you expect.

7. Look at the whole of you program and see where you could improve it. For example: What happens if a resource doesn't exist? What happens if you can't write to the local file system for some reason?

Once you have looked at this problem again, feel free to post your code and ask for advice. It really helps if you can point out what isn't working. Hopefully doing things in stages will help both you and us work out where the problems are.

Have fun
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!