Solved

Java program to download files from the internet

Posted on 2006-06-10
2
178 Views
Last Modified: 2010-03-31
I need to write a java program that can download files from the internet,can anybody help me with how to go about it,any reading material or pieces of code that wud make me understand how to do it and what technology do i use.also can somebody write one such program and post it here,thanks in advance.
0
Comment
Question by:venban
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 10

Expert Comment

by:mukundha_expert
ID: 16876375
Give the URL of your file in the internet in the String. the result will be stored in result. If you know the type of file you are getting eg., .doc or .pdf give the extension to the file name.

                          String str = "Your File URL" ;
               URL url = new URL ( str ) ;
            
                  URLConnection connect  = url.openConnection() ;
            
                FileOutputStream out = new FileOutputStream ( "result" ) ;
BufferedInputStream input = new BufferedInputStream ( connect .getInputStream() ) ;
            
            int ret = -1 ;
            
            while ( (ret = input.read() ) != -1 )
            {
                  out.write( ret ) ;
            }
            
            out.close() ;
            input.close() ;

Cheers,
Mukundh
0
 
LVL 26

Accepted Solution

by:
ksivananth earned 500 total points
ID: 16876487
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Html split(text) 2 49
Firefox and firebub 5 26
Java regex 5 21
Selenium WebElement Login button findElement 9 17
Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Suggested Courses

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question