Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Java program to download files from the internet

Posted on 2006-06-10
2
Medium Priority
?
188 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 2000 total points
ID: 16876487
0

Featured Post

The top UI technologies you need to be aware of

An important part of the job as a front-end developer is to stay up to date and in contact with new tools, trends and workflows. That’s why you cannot miss this upcoming webinar to explore the latest trends in UI technologies!

Question has a verified solution.

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

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
Suggested Courses

661 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